refactor: remove patch_detector and use gameVersion field in match_collector
All checks were successful
pipeline / lint-and-format (push) Successful in 4m20s
pipeline / build-and-push-images (push) Successful in 1m20s

This commit is contained in:
2026-04-30 10:37:42 +02:00
parent e1ab81854a
commit 7051ace13f
16 changed files with 379 additions and 2617 deletions

View File

@@ -19,11 +19,38 @@ async function connectToDatabase() {
return client
}
async function fetchLatestPatch(client: MongoClient) {
const database = client.db('patches')
const patches = database.collection('patches')
const latestPatch = await patches.find().limit(1).sort({ date: -1 }).next()
return latestPatch!.patch as string
/**
* Get the latest patch from existing match collections in the database.
* Collections are named like "15.1_EUW1", "15.2_NA1", etc.
*/
async function fetchLatestPatch(client: MongoClient): Promise<string> {
const matchesDb = client.db('matches')
const collections = await matchesDb.listCollections().toArray()
const collectionNames = collections.map(c => c.name)
// Extract unique patch versions from collection names
const patches = new Set<string>()
for (const name of collectionNames) {
// Collection names are either "patch_platform" or just "patch"
const patch = name.split('_')[0]
if (patch && /^\d+\.\d+$/.test(patch)) {
patches.add(patch)
}
}
if (patches.size === 0) {
throw new Error('No patch collections found in database')
}
// Sort patches and return the latest (highest version number)
const sortedPatches = Array.from(patches).sort((a, b) => {
const [aMajor, aMinor] = a.split('.').map(Number)
const [bMajor, bMinor] = b.split('.').map(Number)
if (aMajor !== bMajor) return bMajor - aMajor
return bMinor - aMinor
})
return sortedPatches[0]
}
/**