refactor/match_collector: refactor platform handling logic

This commit is contained in:
2026-04-23 18:08:17 +02:00
parent a5728a147f
commit 360be86c10
4 changed files with 140 additions and 83 deletions

View File

@@ -5,22 +5,7 @@ import { MongoClient } from 'mongodb'
import champion_stat from './champion_stat'
import { Match } from './api'
// Region configuration: platform -> regional routing value
const PLATFORMS: Record<string, string> = {
EUW1: 'EUROPE',
EUN1: 'EUROPE',
NA1: 'AMERICAS',
KR: 'ASIA'
}
function getPlatformBaseUrl(platform: string): string {
return `https://${platform.toLowerCase()}.api.riotgames.com`
}
function getRegionalBaseUrl(region: string): string {
return `https://${region.toLowerCase()}.api.riotgames.com`
}
import { PLATFORMS, getPlatformBaseUrl, getRegionalBaseUrl, getRegionForPlatform } from './platform'
main()
@@ -75,7 +60,7 @@ async function main() {
// Determine region from matchId (format: PLATFORM_matchId)
// Map platform prefix to regional routing value for match API
const matchPlatformPrefix = game.split('_')[0]
const matchRegion = PLATFORMS[matchPlatformPrefix] || region
const matchRegion = getRegionForPlatform(matchPlatformPrefix) || region
const gameMatch = await match(game, matchRegion)
const gameTimeline = await matchTimeline(game, matchRegion)
gameMatch.timeline = gameTimeline