From 8e69f74f0113ba3c94c7100a47cae24ceab7c6ba Mon Sep 17 00:00:00 2001 From: Suhyun Park Date: Mon, 2 Dec 2024 13:17:35 +0900 Subject: [PATCH] fix: duplicate removal when team name differs between regions --- app/2025/data/championship.ts | 20 +++++++++++++++++++- app/2025/data/same_teams.json | 6 ++++++ 2 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 app/2025/data/same_teams.json diff --git a/app/2025/data/championship.ts b/app/2025/data/championship.ts index 8a94b91..c9e9bb2 100644 --- a/app/2025/data/championship.ts +++ b/app/2025/data/championship.ts @@ -9,6 +9,8 @@ import { TeamRankStatus, } from "./types"; +import sameTeams from "./same_teams.json"; + const createFauxTeams = ( region: Region, count: number @@ -26,6 +28,19 @@ const createFauxTeams = ( }; export const combineRegions = (regions: Region[]) => { + const sameTeamsMap = new Map(); + sameTeams.forEach((team) => { + const { institution, names } = team; + names.sort((a, b) => a.localeCompare(b)); + const teamIdBase = `${institution}$$${names[0]}`; + names.forEach((name) => { + const teamId = `${institution}$$${name}`; + if (teamIdBase !== teamId) { + sameTeamsMap.set(teamId, teamIdBase); + } + }); + }); + const teams: ChampionshipTeamLike[] = regions .map((region) => ({ region, @@ -61,7 +76,10 @@ export const combineRegions = (regions: Region[]) => { const teamIdsSet = new Set(); const instituteCountMap = new Map(); teams.forEach((team) => { - const teamId = `${team.institution}$$${team.teamName}`; + const teamIdTemp = `${team.institution}$$${team.teamName}`; + const teamId = sameTeamsMap.has(teamIdTemp) + ? sameTeamsMap.get(teamIdTemp)! + : teamIdTemp; if (teamIdsSet.has(teamId)) { team.status = TeamRankInCombinedScoreboardStatus.D4_2_1; return; diff --git a/app/2025/data/same_teams.json b/app/2025/data/same_teams.json new file mode 100644 index 0000000..4847a98 --- /dev/null +++ b/app/2025/data/same_teams.json @@ -0,0 +1,6 @@ +[ + { + "institution": "Jeonbuk National University", + "names": ["2358and14", "2 3 5 8 14"] + } +]