Skip to content

Commit

Permalink
fix: duplicate removal when team name differs between regions
Browse files Browse the repository at this point in the history
  • Loading branch information
shiftpsh committed Dec 2, 2024
1 parent acbca68 commit 8e69f74
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
20 changes: 19 additions & 1 deletion app/2025/data/championship.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import {
TeamRankStatus,
} from "./types";

import sameTeams from "./same_teams.json";

const createFauxTeams = (
region: Region,
count: number
Expand All @@ -26,6 +28,19 @@ const createFauxTeams = (
};

export const combineRegions = (regions: Region[]) => {
const sameTeamsMap = new Map<string, string>();
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,
Expand Down Expand Up @@ -61,7 +76,10 @@ export const combineRegions = (regions: Region[]) => {
const teamIdsSet = new Set<string>();
const instituteCountMap = new Map<string, number>();
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;
Expand Down
6 changes: 6 additions & 0 deletions app/2025/data/same_teams.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[
{
"institution": "Jeonbuk National University",
"names": ["2358and14", "2 3 5 8 14"]
}
]

0 comments on commit 8e69f74

Please sign in to comment.