Skip to content

Commit c795bc6

Browse files
committed
fix: Error in background job that looks for updated files
1 parent 2aeecf5 commit c795bc6

File tree

1 file changed

+25
-4
lines changed

1 file changed

+25
-4
lines changed

CFLookup/Jobs/GetLatestUpdatedModPerGame.cs

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using Hangfire.Server;
77
using Microsoft.Data.SqlClient;
88
using StackExchange.Redis;
9+
using System.Data;
910
using System.Text;
1011
using System.Text.Json;
1112

@@ -32,15 +33,15 @@ public async static Task RunAsync(PerformContext context)
3233
Mod? latestUpdatedModData = null;
3334
CurseForge.APIClient.Models.Files.File? latestUpdatedFileData = null;
3435

35-
var privateGames = await db.ExecuteListAsync<int>(
36-
"SELECT GameId FROM ProcessingGames WHERE Disabled = 0 AND ModCount > 0"
36+
var privateGames = await db.ExecuteListAsync<ProcessingGames>(
37+
"SELECT * FROM ProcessingGames WHERE Disabled = 0 AND ModCount > 0"
3738
);
3839

3940
foreach (var privateGame in privateGames)
4041
{
41-
if (!allGames.Any(g => g.Id == privateGame))
42+
if (!allGames.Any(g => g.Id == privateGame.GameId))
4243
{
43-
var game = await cfClient.GetGameAsync(privateGame);
44+
var game = await cfClient.GetGameAsync(privateGame.GameId);
4445
if (game != null && game.Data != null)
4546
{
4647
allGames.Add(game.Data);
@@ -161,4 +162,24 @@ await db.ExecuteNonQueryAsync(
161162
}
162163
}
163164
}
165+
166+
public class ProcessingGames
167+
{
168+
public long Id { get; set; }
169+
public int GameId { get; set; }
170+
public string GameName { get; set; }
171+
public long? ModCount { get; set; }
172+
public bool Disabled { get; set; }
173+
public DateTime LastUpdate { get; set; }
174+
175+
public ProcessingGames(DataRow row)
176+
{
177+
Id = (long)row["Id"];
178+
GameId = (int)row["GameId"];
179+
GameName = (string)row["GameName"];
180+
ModCount = (long)row["ModCount"];
181+
Disabled = (bool)row["Disabled"];
182+
LastUpdate = (DateTime)row["LastUpdate"];
183+
}
184+
}
164185
}

0 commit comments

Comments
 (0)