경기 탭 리플레이 필터: 리플레이 있는 경기 / 없는 경기 (게임 PC 에 발로란트 .vrf 가 있는지, GET /api/matches?replay=yes|no · 롤 제외 · 요약에 replay) · 예전 앱이면 업데이트 안내 · 롤을 고르면 숨김 · '필터 초기화' · 목 서버 · 시험 · v1.12.0
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -318,9 +318,16 @@ export async function buildApi(d: ApiDeps): Promise<FastifyInstance> {
|
||||
|
||||
app.get<{ Querystring: Record<string, string> }>('/api/matches', async (req) => {
|
||||
const q = req.query;
|
||||
// 리플레이 필터 (v1.12.0): yes = 이 PC 에 리플레이 파일(.vrf)이 있는 발로란트 경기, no = 없는 발로란트 경기
|
||||
const replay = q.replay === 'yes' || q.replay === 'no' ? q.replay : undefined;
|
||||
if (replay && q.game && q.game !== 'valorant') return [];
|
||||
const replayIds = d.replays ? d.replays.list().map((r) => `val-${r.matchId}`) : [];
|
||||
const hasReplay = new Set(replayIds);
|
||||
return store
|
||||
.listMatches({
|
||||
game: q.game || undefined,
|
||||
game: replay ? 'valorant' : q.game || undefined,
|
||||
ids: replay === 'yes' ? replayIds : undefined,
|
||||
skipIds: replay === 'no' ? replayIds : undefined,
|
||||
before: q.before ? Number(q.before) : undefined,
|
||||
after: q.after ? Number(q.after) : undefined,
|
||||
limit: q.limit ? Math.min(Number(q.limit), 200) : 50,
|
||||
@@ -330,7 +337,11 @@ export async function buildApi(d: ApiDeps): Promise<FastifyInstance> {
|
||||
onlyModes: q.mode ? d.games.modeKeys((name) => name === q.mode) : undefined,
|
||||
skipModes: d.games.modeKeys((name) => name === HIDDEN_MODE),
|
||||
})
|
||||
.map((m) => d.games.summary(m));
|
||||
.map((m) => {
|
||||
const s = d.games.summary(m);
|
||||
if (d.replays && m.game === 'valorant') s.replay = hasReplay.has(m.id);
|
||||
return s;
|
||||
});
|
||||
});
|
||||
// 모드 필터 목록 (v1.11.0): 모드 이름별 경기 수
|
||||
app.get<{ Querystring: Record<string, string> }>('/api/matches/modes', async (req) => d.games.modeList(req.query.game || undefined));
|
||||
|
||||
@@ -447,6 +447,8 @@ export class Store {
|
||||
after?: number;
|
||||
limit?: number;
|
||||
ids?: string[];
|
||||
/** 이 경기들은 빼고 (리플레이 없는 경기 필터, v1.12.0) */
|
||||
skipIds?: string[];
|
||||
has?: 'timeline' | 'voice';
|
||||
onlyModes?: ModeKey[];
|
||||
skipModes?: ModeKey[];
|
||||
@@ -482,6 +484,10 @@ export class Store {
|
||||
where.push(`id IN (${opts.ids.map(() => '?').join(',')})`);
|
||||
args.push(...opts.ids);
|
||||
}
|
||||
if (opts.skipIds?.length) {
|
||||
where.push(`id NOT IN (${opts.skipIds.map(() => '?').join(',')})`);
|
||||
args.push(...opts.skipIds);
|
||||
}
|
||||
return this.db
|
||||
.prepare(`SELECT * FROM matches ${where.length ? 'WHERE ' + where.join(' AND ') : ''} ORDER BY started_at DESC LIMIT ?`)
|
||||
.all(...args, opts.limit ?? 50) as MatchRow[];
|
||||
|
||||
Reference in New Issue
Block a user