style(api): apply prettier formatting
This commit is contained in:
1 parent
80fef25af3
commit
96fede9fe5
75 files changed
+955
-674
No files matched your search
@@ -45,8 +45,20 @@ export async function migrateTeamIndex(
|
||||
changedMatches: 0,
|
||||
};
|
||||
|
||||
await migrateCollection(db.collection('auction'), options.limit, dryRun, stats, 'auction');
|
||||
await migrateCollection(db.collection('match'), options.limit, dryRun, stats, 'match');
|
||||
await migrateCollection(
|
||||
db.collection('auction'),
|
||||
options.limit,
|
||||
dryRun,
|
||||
stats,
|
||||
'auction',
|
||||
);
|
||||
await migrateCollection(
|
||||
db.collection('match'),
|
||||
options.limit,
|
||||
dryRun,
|
||||
stats,
|
||||
'match',
|
||||
);
|
||||
|
||||
return stats;
|
||||
}
|
||||
@@ -60,7 +72,7 @@ async function migrateCollection(
|
||||
) {
|
||||
const cursor = collection.find({}).limit(limit ?? 0);
|
||||
const writes: Array<{
|
||||
updateOne: {
|
||||
updateOne: {
|
||||
filter: { _id: unknown };
|
||||
update: { $set: Record<string, unknown>; $unset: Record<string, ''> };
|
||||
};
|
||||
@@ -143,7 +155,8 @@ function migrateMatch(doc: AnyDoc) {
|
||||
const migrated = { ...team };
|
||||
const teamIndex = readTeamIndex(migrated);
|
||||
if (teamIndex !== undefined) migrated.teamIndex = teamIndex;
|
||||
if (!migrated.name && typeof teamIndex === 'number') migrated.name = `${teamIndex}팀`;
|
||||
if (!migrated.name && typeof teamIndex === 'number')
|
||||
migrated.name = `${teamIndex}팀`;
|
||||
if ('side' in migrated || 'groupIndex' in migrated) changed = true;
|
||||
delete migrated.side;
|
||||
delete migrated.groupIndex;
|
||||
@@ -200,7 +213,10 @@ function migrateResult(result: Record<string, unknown>) {
|
||||
migrated.games = games;
|
||||
|
||||
const seriesResults = asArray(result.seriesResults).map((series) => {
|
||||
if (typeof series.teamAIndex === 'number' && typeof series.teamBIndex === 'number') {
|
||||
if (
|
||||
typeof series.teamAIndex === 'number' &&
|
||||
typeof series.teamBIndex === 'number'
|
||||
) {
|
||||
return series;
|
||||
}
|
||||
changed = true;
|
||||
@@ -216,7 +232,9 @@ function migrateResult(result: Record<string, unknown>) {
|
||||
const teamBIndex = Math.max(legacyBlueTeamIndex, legacyRedTeamIndex);
|
||||
const blueScore = numberOrDefault(series.blueScore, 0);
|
||||
const redScore = numberOrDefault(series.redScore, 0);
|
||||
const winnerSide = isSide(series.winnerSide) ? series.winnerSide : undefined;
|
||||
const winnerSide = isSide(series.winnerSide)
|
||||
? series.winnerSide
|
||||
: undefined;
|
||||
const winnerTeamIndex =
|
||||
winnerSide === 'blue'
|
||||
? legacyBlueTeamIndex
|
||||
@@ -231,7 +249,8 @@ function migrateResult(result: Record<string, unknown>) {
|
||||
winnerTeamIndex,
|
||||
};
|
||||
});
|
||||
migrated.seriesResults = seriesResults.length > 0 ? seriesResults : buildSeries(games);
|
||||
migrated.seriesResults =
|
||||
seriesResults.length > 0 ? seriesResults : buildSeries(games);
|
||||
|
||||
if (typeof migrated.winnerTeamIndex !== 'number') {
|
||||
const migratedSeriesResults = Array.isArray(migrated.seriesResults)
|
||||
@@ -244,7 +263,11 @@ function migrateResult(result: Record<string, unknown>) {
|
||||
: undefined);
|
||||
}
|
||||
|
||||
if ('winnerSide' in migrated || 'blueScore' in migrated || 'redScore' in migrated) {
|
||||
if (
|
||||
'winnerSide' in migrated ||
|
||||
'blueScore' in migrated ||
|
||||
'redScore' in migrated
|
||||
) {
|
||||
changed = true;
|
||||
}
|
||||
delete migrated.winnerSide;
|
||||
@@ -272,8 +295,12 @@ function buildSeries(games: Record<string, unknown>[]) {
|
||||
const teamAIndex = Math.min(blueTeamIndex, redTeamIndex);
|
||||
const teamBIndex = Math.max(blueTeamIndex, redTeamIndex);
|
||||
const key = `${teamAIndex}:${teamBIndex}`;
|
||||
const current =
|
||||
bySeries.get(key) ?? { teamAIndex, teamBIndex, teamAWins: 0, teamBWins: 0 };
|
||||
const current = bySeries.get(key) ?? {
|
||||
teamAIndex,
|
||||
teamBIndex,
|
||||
teamAWins: 0,
|
||||
teamBWins: 0,
|
||||
};
|
||||
if (winnerTeamIndex === teamAIndex) current.teamAWins += 1;
|
||||
if (winnerTeamIndex === teamBIndex) current.teamBWins += 1;
|
||||
current.winnerTeamIndex =
|
||||
@@ -331,5 +358,7 @@ function numberOrDefault(value: unknown, fallback: number) {
|
||||
}
|
||||
|
||||
function numberOrUndefined(value: unknown) {
|
||||
return typeof value === 'number' && Number.isFinite(value) ? value : undefined;
|
||||
return typeof value === 'number' && Number.isFinite(value)
|
||||
? value
|
||||
: undefined;
|
||||
}
|
||||
Reference in new issue
Block a user