refactor/match_collector: refactor platform handling logic
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user