Skip to content

Commit 218860a

Browse files
authored
Merge pull request #39 from thejaviertc/dev
v1.3.0
2 parents 2e51251 + ba4d31d commit 218860a

File tree

9 files changed

+33
-8
lines changed

9 files changed

+33
-8
lines changed

.github/workflows/cd.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
runs-on: ubuntu-latest
1010
steps:
1111
- name: 🚚 Get latest code
12-
uses: actions/checkout@v4
12+
uses: actions/checkout@v5
1313
with:
1414
fetch-depth: 0
1515

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
runs-on: ubuntu-latest
1010
steps:
1111
- name: 🚚 Get latest code
12-
uses: actions/checkout@v4
12+
uses: actions/checkout@v5
1313
with:
1414
fetch-depth: 0
1515

SteamWorkshopStats/Controllers/UserController.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ private async Task<ActionResult<User>> GetUserAsync(string steamId)
7676
Favorites = addons.Sum(addon => addon.Favorites),
7777
Likes = addons.Sum(addon => addon.Likes),
7878
Dislikes = addons.Sum(addon => addon.Dislikes),
79+
Awards = addons.Sum(addon => addon.Awards),
7980
Addons = addons,
8081
};
8182

SteamWorkshopStats/Models/Addon.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace SteamWorkshopStats.Models;
1+
namespace SteamWorkshopStats.Models;
22

33
public struct Addon : IComparable<Addon>, IEquatable<Addon>
44
{
@@ -18,6 +18,8 @@ public struct Addon : IComparable<Addon>, IEquatable<Addon>
1818

1919
public int Dislikes { get; init; }
2020

21+
public int Awards { get; init; }
22+
2123
public int Stars { get; init; }
2224

2325
public static int GetNumberOfStars(int votes, float score)

SteamWorkshopStats/Models/Records/GetUserFiles.cs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System.Text.Json.Serialization;
1+
using System.Text.Json.Serialization;
22

33
namespace SteamWorkshopStats.Models.Records;
44

@@ -13,6 +13,14 @@ public record class GetUserFilesResponse
1313
[JsonPropertyName("publishedfiledetails")]
1414
public ICollection<PublishedFile>? PublishedFiles { get; init; }
1515
}
16+
public record class Reaction
17+
{
18+
[JsonPropertyName("reactionid")]
19+
public int ReactionId { get; init; }
20+
21+
[JsonPropertyName("count")]
22+
public int Count { get; init; }
23+
}
1624

1725
public record class PublishedFile
1826
{
@@ -36,6 +44,10 @@ public record class PublishedFile
3644

3745
[JsonPropertyName("vote_data")]
3846
public required VoteData Votes { get; init; }
47+
48+
[JsonPropertyName("reactions")]
49+
public List<Reaction>? Reactions { get; init; }
50+
public int Awards => Reactions?.Sum(r => r.Count) ?? 0;
3951
}
4052

4153
public record class VoteData

SteamWorkshopStats/Models/User.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace SteamWorkshopStats.Models;
1+
namespace SteamWorkshopStats.Models;
22

33
public struct User : IEquatable<User>
44
{
@@ -18,6 +18,8 @@ public struct User : IEquatable<User>
1818

1919
public int Dislikes { get; init; }
2020

21+
public int Awards { get; init; }
22+
2123
public ICollection<Addon> Addons { get; init; }
2224

2325
public bool Equals(User other)

SteamWorkshopStats/Services/DiscordService.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,12 @@ public async Task LogUserAsync(User user)
119119
value = user.Dislikes,
120120
inline = true,
121121
},
122+
new
123+
{
124+
name = "Awards",
125+
value = user.Awards,
126+
inline = true,
127+
},
122128
},
123129
thumbnail = new { url = user.ProfileImageUrl },
124130
timestamp = DateTime.UtcNow,

SteamWorkshopStats/Services/SteamService.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using NLog;
1+
using NLog;
22
using SteamWorkshopStats.Exceptions;
33
using SteamWorkshopStats.Models;
44
using SteamWorkshopStats.Models.Records;
@@ -7,6 +7,7 @@ namespace SteamWorkshopStats.Services;
77

88
public class SteamService : ISteamService
99
{
10+
1011
private readonly IConfiguration _configuration;
1112

1213
private readonly IHttpClientFactory _httpClientFactory;
@@ -92,7 +93,7 @@ public async Task<List<Addon>> GetAddonsAsync(string steamId)
9293
HttpClient client = _httpClientFactory.CreateClient("SteamClient");
9394

9495
HttpResponseMessage response = await client.GetAsync(
95-
$"IPublishedFileService/GetUserFiles/v1/?key={_configuration["SteamApiKey"]}&steamid={steamId}&numperpage=500&return_vote_data=true"
96+
$"IPublishedFileService/GetUserFiles/v1/?key={_configuration["SteamApiKey"]}&steamid={steamId}&numperpage=500&return_vote_data=true&return_reactions=true"
9697
);
9798

9899
if (!response.IsSuccessStatusCode)
@@ -125,6 +126,7 @@ public async Task<List<Addon>> GetAddonsAsync(string steamId)
125126
Favorites = addon.Favorites,
126127
Likes = likes,
127128
Dislikes = dislikes,
129+
Awards = addon.Awards,
128130
Stars = Addon.GetNumberOfStars(likes + dislikes, addon.Votes.Score),
129131
}
130132
);

SteamWorkshopStats/SteamWorkshopStats.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
</PropertyGroup>
1010

1111
<ItemGroup>
12-
<PackageReference Include="NLog" Version="5.4.0" />
12+
<PackageReference Include="NLog" Version="6.0.3" />
1313
</ItemGroup>
1414

1515
<ItemGroup>

0 commit comments

Comments
 (0)