Skip to content

Commit 879826c

Browse files
committed
feat: Use a database to keep track of all games we want to check for updates
1 parent 9d9608d commit 879826c

File tree

1 file changed

+9
-169
lines changed

1 file changed

+9
-169
lines changed

CFLookup/Jobs/GetLatestUpdatedModPerGame.cs

Lines changed: 9 additions & 169 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ namespace CFLookup.Jobs
1414
[AutomaticRetry(Attempts = 0)]
1515
public class GetLatestUpdatedModPerGame
1616
{
17-
public static async Task RunAsync(PerformContext context)
17+
public async static Task RunAsync(PerformContext context)
1818
{
1919
using (var scope = Program.ServiceProvider.CreateScope())
2020
{
@@ -27,179 +27,14 @@ public static async Task RunAsync(PerformContext context)
2727
Console.WriteLine("Fetching all games");
2828

2929
var allGames = new List<Game>();
30-
var games = await cfClient.GetGamesAsync();
31-
await Task.Delay(100);
32-
if (games != null && games.Pagination.ResultCount > 0)
33-
{
34-
allGames.AddRange(games.Data);
35-
var index = 0;
36-
while (games.Pagination.ResultCount > 0)
37-
{
38-
index += games.Pagination.PageSize;
39-
games = await cfClient.GetGamesAsync(index);
40-
await Task.Delay(100);
41-
allGames.AddRange(games.Data);
42-
}
43-
}
44-
45-
Console.WriteLine($"Fetched {allGames.Count} games");
4630

4731
DateTimeOffset lastUpdatedMod = DateTimeOffset.MinValue;
4832
Mod? latestUpdatedModData = null;
4933
CurseForge.APIClient.Models.Files.File? latestUpdatedFileData = null;
5034

51-
var privateGames = new List<int>
52-
{
53-
1, // World of Warcraft
54-
64, // The Secret World
55-
65, // StarCraft II
56-
68, // Fallout 3
57-
202, // Warcraft III: Reign of Chaos
58-
335, // Runes of Magic
59-
423, // World of Tanks
60-
424, // Rift
61-
431, // Terraria
62-
432, // Minecraft
63-
447, // Fallout: New Vegas
64-
449, // The Elder Scrolls V: Skyrim
65-
454, // WildStar
66-
455, // The Elder Scrolls Online
67-
465, // Counter-Strike: Global Offensive
68-
496, // Grand Theft Auto V
69-
504, // Euro Truck Simulator 2
70-
540, // 7 Days to Die
71-
608, // Darkest Dungeon
72-
632, // Rocket League
73-
646, // Fallout 4
74-
661, // Factorio
75-
669, // Stardew Valley
76-
727, // Sid Meier's Civilization VI
77-
732, // Planet Coaster
78-
4401, // Kerbal Space Program
79-
4455, // Secret World Legends
80-
4482, // Subnautica
81-
4588, // RimWorld
82-
4593, // Final Fantasy XV
83-
4611, // XCOM 2
84-
4619, // The Last of Us
85-
4741, // Final Fantasy IV
86-
4773, // Final Fantasy VI
87-
4819, // American Truck Simulator
88-
4892, // Space Engineers
89-
5001, // Final Fantasy II
90-
5002, // Mario Party 2
91-
5021, // Final Fantasy V
92-
5026, // Final Fantasy III
93-
5230, // Final Fantasy I
94-
6222, // BattleTech
95-
6351, // Mario Party 3
96-
6647, // My Time at Portia
97-
6820, // Kenshi
98-
6999, // Big Pharma
99-
7005, // System Shock
100-
8612, // Euro Truck Simulator
101-
8686, // Jurassic Park: Operation Genesis
102-
8892, // Microsoft Flight Simulator
103-
11805, // Zoo Tycoon 2
104-
12471, // Rend
105-
14331, // WarGroove
106-
18237, // Staxel
107-
22184, // New World
108-
22191, // Frostpunk
109-
48907, // Beat It!
110-
51667, // Dead Island 2
111-
57483, // Days Gone
112-
57972, // Phantom Brigade
113-
58024, // Vintage Story
114-
58053, // Jurassic World Evolution
115-
58234, // Warhammer: Vermintide 2
116-
61489, // Surviving Mars
117-
64244, // Farming Simulator 19
118-
65814, // Fallout 76
119-
66004, // Starfield
120-
66022, // Satisfactory
121-
67850, // Bloons TD 6
122-
68013, // Valheim
123-
69073, // Megaquarium
124-
69271, // Minecraft Dungeons
125-
69761, // Among Us
126-
70667, // Chronicles of Arcadia
127-
70752, // Subnautica: Below Zero
128-
71010, // Darkest Dungeon 2
129-
71638, // The Riftbreaker
130-
71878, // Planet Zoo
131-
72430, // Watch Dogs Legion
132-
72458, // Baldur's Gate 3
133-
73492, // Kerbal Space Program 2
134-
75009, // Sons of the Forest
135-
76592, // XCOM: Chimera Squad
136-
77546, // Resident Evil Village
137-
77548, // Returnal
138-
78017, // Dyson Sphere Program
139-
78018, // osu!
140-
78019, // Loop Hero
141-
78022, // Minecraft Bedrock
142-
78023, // Timber and Stone
143-
78062, // The Sims 4
144-
78072, // Hometopia
145-
78101, // Tiny Life
146-
78103, // art of rally
147-
78135, // Demeo
148-
78163, // Astro Colony
149-
78225, // The Anacrusis
150-
78251, // Kingshunt
151-
78496, // Hero's Hour
152-
79630, // GTA-SA
153-
79805, // CurseForge Demo
154-
80016, // Mario Party
155-
80214, // Spider-Man Remastered
156-
80345, // Dwerve
157-
81975, // LEAP
158-
82010, // KSP QA Test Game
159-
82047, // Oaken
160-
82164, // Unity SDK Tester
161-
82203, // Conquer Online
162-
83357, // River City Girls 2
163-
83372, // The Settlers: New Allies
164-
83374, // ARK Survival Ascended
165-
83375, // Far Cry 6
166-
83387, // Wild Hearts
167-
83388, // Company of Heroes 3
168-
83431, // Wo Long Fallen Dynasty
169-
83432, // Resident Evil 4 Remake
170-
83444, // WorldBox - God Simulator
171-
83445, // V Rising
172-
83452, // Crime Boss: Rockay City
173-
83453, // Minecraft Legends
174-
83454, // Star Wars Jedi Survivor
175-
83457, // Redfall
176-
83461, // Darkest Dungeon II
177-
83462, // Endless Dungeon
178-
83463, // Suicide Squad: Kill the Justice League
179-
83634, // Age of Wonders 4
180-
83644, // Starship Troopers: Extermination
181-
83645, // Terra Nil
182-
83647, // Brinefall
183-
83648, // Spiritfall
184-
83649, // Meet Your Maker
185-
83871, // Street Fighter 6
186-
83981, // Unreal Test Game
187-
84062, // Rushdown Revolt
188-
84137, // Tennis Elbow 4
189-
84438, // Trine 5
190-
84439, // Mortal Kombat 1
191-
84529, // NighspadeTest001
192-
84530, // OWITestGame
193-
84610, // Test01
194-
84658, // AI M3
195-
84749, // Minecraft
196-
84801, // stopdeletingmystuffiamtesting
197-
84810, // Oaken_Testing
198-
84932, // MINIcraft
199-
85196, // Palworld
200-
87986, // Hogwarts Legacy
201-
88849, // inZOI
202-
};
35+
var privateGames = await db.ExecuteListAsync<int>(
36+
"SELECT GameId FROM ProcessingGames WHERE Disabled = 0 AND ModCount > 0"
37+
);
20338

20439
foreach (var privateGame in privateGames)
20540
{
@@ -224,6 +59,11 @@ public static async Task RunAsync(PerformContext context)
22459
var latestUpdatedMod = await cfClient.SearchModsAsync(game.Id, sortField: ModsSearchSortField.LastUpdated, sortOrder: ModsSearchSortOrder.Descending, pageSize: 1);
22560
if (latestUpdatedMod != null && latestUpdatedMod.Pagination.ResultCount > 0)
22661
{
62+
await db.ExecuteNonQueryAsync("UPDATE ProcessingGames SET LastUpdate = GETUTCDATE(), ModCount = @modCount WHERE GameId = @gameId",
63+
new SqlParameter("@modCount", latestUpdatedMod.Pagination.ResultCount),
64+
new SqlParameter("@gameId", game.Id)
65+
);
66+
22767
var mod = latestUpdatedMod.Data.First();
22868
var latestUpdatedFile = mod.LatestFiles.OrderByDescending(f => f.FileDate).FirstOrDefault();
22969
if (latestUpdatedFile != null)

0 commit comments

Comments
 (0)