feat: improve tournament workflows and prune outdated docs

This commit is contained in:
dahyeon committed 2026-11-10 15:31:19 +09:00
1 parent da7b502936
commit 38a89b5374
53 files changed
+3308 -3276

No files matched your search

@@ -0,0 +1,86 @@
import type { MatchDetailResponse } from '@lolympus/contracts';
const scheduleFormatter = new Intl.DateTimeFormat('ko-KR', {
timeZone: 'Asia/Seoul',
month: 'numeric',
day: 'numeric',
weekday: 'short',
hour: '2-digit',
minute: '2-digit',
hourCycle: 'h23',
});
export const HOME_MATCH_STATUS = {
recruiting: '모집 중',
'team-built': '팀빌딩',
'in-progress': '진행 중',
finished: '종료',
} as const;
export function getHomeMatchSchedule(scheduledAt: string) {
const value = new Date(scheduledAt);
if (Number.isNaN(value.getTime())) return;
const { month, day, weekday, hour, minute } = Object.fromEntries(
scheduleFormatter
.formatToParts(value)
.map(({ type, value }) => [type, value]),
);
const time = `${hour}:${minute}`;
return {
date: `${month}월 ${day}일 (${weekday})`,
compact: `${month}/${day} (${weekday}) ${time}`,
month,
day,
weekday,
hour,
minute,
time,
};
}
export function getHistoryMatchTitle(
title: string,
schedule: ReturnType<typeof getHomeMatchSchedule>,
) {
if (!schedule) return title;
// Only shorten a generic date-based title when its entire date and time match the row.
const generic =
/^(\d{1,2})\/(\d{1,2})\s*\(([월화수목금토일])\)\s*(\d{1,2})(?:시(?:\s*(\d{1,2})분)?|:(\d{2}))\s*(정기\s*내전|내전)$/u.exec(
title.trim(),
);
if (!generic) return title;
const [, month, day, weekday, hour, minutes, colonMinutes, name] = generic;
return Number(month) === Number(schedule.month) &&
Number(day) === Number(schedule.day) &&
weekday === schedule.weekday &&
Number(hour) === Number(schedule.hour) &&
Number(minutes ?? colonMinutes ?? 0) === Number(schedule.minute)
? name
: title;
}
export function getHomeMatchEnrollment(
match: Pick<
MatchDetailResponse,
'status' | 'joined' | 'participants' | 'maxParticipants'
>,
) {
const current = match.participants.length;
const remaining = match.maxParticipants - current;
const isRecruiting = match.status === 'recruiting';
const canApply = isRecruiting && remaining > 0 && !match.joined;
const capacity =
match.maxParticipants > 0
? `${current}/${match.maxParticipants}명`
: `${current}명`;
const label =
isRecruiting && match.joined
? '참가 완료'
: canApply
? `${remaining}자리 남음`
: '모집 마감';
return { canApply, capacity, label };
}