From e8a1c4d5b354edd925aff21580802b8e0be20557 Mon Sep 17 00:00:00 2001 From: EJClaw Date: Sat, 21 Nov 2026 11:49:18 +0900 Subject: [PATCH] =?UTF-8?q?=EA=B2=BD=EA=B8=B0=20=ED=83=AD=20=EB=A6=AC?= =?UTF-8?q?=ED=94=8C=EB=A0=88=EC=9D=B4=20=ED=95=84=ED=84=B0:=20=EB=A6=AC?= =?UTF-8?q?=ED=94=8C=EB=A0=88=EC=9D=B4=20=EC=9E=88=EB=8A=94=20=EA=B2=BD?= =?UTF-8?q?=EA=B8=B0=20/=20=EC=97=86=EB=8A=94=20=EA=B2=BD=EA=B8=B0=20(?= =?UTF-8?q?=EA=B2=8C=EC=9E=84=20PC=20=EC=97=90=20=EB=B0=9C=EB=A1=9C?= =?UTF-8?q?=EB=9E=80=ED=8A=B8=20.vrf=20=EA=B0=80=20=EC=9E=88=EB=8A=94?= =?UTF-8?q?=EC=A7=80,=20GET=20/api/matches=3Freplay=3Dyes|no=20=C2=B7=20?= =?UTF-8?q?=EB=A1=A4=20=EC=A0=9C=EC=99=B8=20=C2=B7=20=EC=9A=94=EC=95=BD?= =?UTF-8?q?=EC=97=90=20replay)=20=C2=B7=20=EC=98=88=EC=A0=84=20=EC=95=B1?= =?UTF-8?q?=EC=9D=B4=EB=A9=B4=20=EC=97=85=EB=8D=B0=EC=9D=B4=ED=8A=B8=20?= =?UTF-8?q?=EC=95=88=EB=82=B4=20=C2=B7=20=EB=A1=A4=EC=9D=84=20=EA=B3=A0?= =?UTF-8?q?=EB=A5=B4=EB=A9=B4=20=EC=88=A8=EA=B9=80=20=C2=B7=20'=ED=95=84?= =?UTF-8?q?=ED=84=B0=20=EC=B4=88=EA=B8=B0=ED=99=94'=20=C2=B7=20=EB=AA=A9?= =?UTF-8?q?=20=EC=84=9C=EB=B2=84=20=C2=B7=20=EC=8B=9C=ED=97=98=20=C2=B7=20?= =?UTF-8?q?v1.12.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 5.5 --- app/package-lock.json | 4 ++-- app/package.json | 2 +- app/src/core/api/server.ts | 15 ++++++++++++-- app/src/core/db/db.ts | 6 ++++++ app/test/replays.test.ts | 28 ++++++++++++++++++++++++++ packages/shared/src/protocol.ts | 2 ++ site/web/mock/server.mjs | 7 ++++++- site/web/src/lib/api.ts | 4 +++- site/web/src/pages/UserPages.tsx | 34 +++++++++++++++++++++++--------- 9 files changed, 86 insertions(+), 16 deletions(-) diff --git a/app/package-lock.json b/app/package-lock.json index ff60da9..25a78cc 100644 --- a/app/package-lock.json +++ b/app/package-lock.json @@ -1,12 +1,12 @@ { "name": "gvr-app", - "version": "1.11.2", + "version": "1.12.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "gvr-app", - "version": "1.11.2", + "version": "1.12.0", "license": "UNLICENSED", "dependencies": { "@discordjs/voice": "^0.19.2", diff --git a/app/package.json b/app/package.json index 86b9b05..28bdde8 100644 --- a/app/package.json +++ b/app/package.json @@ -1,7 +1,7 @@ { "name": "gvr-app", "productName": "겜녹이", - "version": "1.11.2", + "version": "1.12.0", "description": "겜녹이 (Game Voice Recorder) - 게임 연동 디스코드 음성 기록", "private": true, "main": "dist/main.cjs", diff --git a/app/src/core/api/server.ts b/app/src/core/api/server.ts index bccfecc..76ae0c8 100644 --- a/app/src/core/api/server.ts +++ b/app/src/core/api/server.ts @@ -318,9 +318,16 @@ export async function buildApi(d: ApiDeps): Promise { app.get<{ Querystring: Record }>('/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 { 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 }>('/api/matches/modes', async (req) => d.games.modeList(req.query.game || undefined)); diff --git a/app/src/core/db/db.ts b/app/src/core/db/db.ts index 6476f28..bdd6555 100644 --- a/app/src/core/db/db.ts +++ b/app/src/core/db/db.ts @@ -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[]; diff --git a/app/test/replays.test.ts b/app/test/replays.test.ts index bcda767..e632d87 100644 --- a/app/test/replays.test.ts +++ b/app/test/replays.test.ts @@ -182,3 +182,31 @@ test('실제 변환기 (tools/replay-extract 리눅스 빌드 + 13.08 리플레 assert.equal(j.players.length, 10); assert.ok(j.kills.length > 100); }); + +test('경기 목록 리플레이 필터: yes = 리플레이 파일이 있는 발로란트 경기, no = 없는 발로란트 경기 (롤 제외) · 요약에 replay', async () => { + const s = setup(); + const app = await buildApi({ + store: s.store, + timeline: new Timeline(s.store), + games: { modeKeys: () => [], summary: (m: any) => ({ id: m.id, game: m.game }) } as any, + dict: {} as any, + culprit: {} as any, + bus: new Bus(), + settings: () => ({}) as any, + trainingDir: () => path.join(s.dir, 'training'), + overviewExtra: () => ({ guild: null, recording: {} as any }), + version: 'test', + replays: s.replays, + }); + const get = async (qs: string) => (await app.inject({ url: `/api/matches${qs}` })).json() as { id: string; replay?: boolean }[]; + // 리플레이를 하나도 안 받았으면 yes 는 빈 목록, no 는 발로란트 경기 전부 + assert.deepEqual(await get('?replay=yes'), []); + assert.deepEqual((await get('?replay=no')).map((m) => m.id), [`val-${ID}`, `val-${ID2}`]); + fs.writeFileSync(path.join(s.demos, `${ID}.vrf`), 'vrf'); + (s.replays as any).scanCache = null; // 10초 목록 캐시 무시 + const all = await get(''); + assert.deepEqual(Object.fromEntries(all.map((m) => [m.id, m.replay])), { [`val-${ID}`]: true, [`val-${ID2}`]: false, 'lol-KR_1': undefined }); + assert.deepEqual((await get('?replay=yes')).map((m) => m.id), [`val-${ID}`]); + assert.deepEqual((await get('?replay=no')).map((m) => m.id), [`val-${ID2}`]); + assert.deepEqual(await get('?replay=no&game=lol'), []); +}); diff --git a/packages/shared/src/protocol.ts b/packages/shared/src/protocol.ts index 7bfd24b..5ca5cb6 100644 --- a/packages/shared/src/protocol.ts +++ b/packages/shared/src/protocol.ts @@ -169,6 +169,8 @@ export interface MatchSummary { source?: 'live' | 'history'; /** 목소리가 녹음된 경기 (잡음 제외, v1.9.0 앱부터) */ voice?: boolean; + /** 발로란트: 이 PC 에 리플레이 파일(.vrf)이 있는 경기 (경기 목록, v1.12.0 앱부터) */ + replay?: boolean; } export interface MatchPlayer { diff --git a/site/web/mock/server.mjs b/site/web/mock/server.mjs index ce0e465..16c749b 100644 --- a/site/web/mock/server.mjs +++ b/site/web/mock/server.mjs @@ -130,9 +130,11 @@ function timeline(q) { return { items: page, next: items.length > limit ? enc(page[page.length - 1]) : null }; } +const hasReplay = (m) => !!m.replayPath && fs.existsSync(m.replayPath); const summary = (m) => ({ id: m.id, game: m.game, startedAt: m.startedAt, endedAt: m.endedAt, map: m.map, mode: m.mode, win: m.win, score: m.score, status: m.status, participants: m.participants, source: m.source ?? 'live', voice: m.utterances.length > 0, + ...(m.game === 'valorant' ? { replay: hasReplay(m) } : {}), }); function userProfile(id) { @@ -361,8 +363,11 @@ async function handle(req, res) { // 모드 · 날짜 필터, 데스매치는 늘 뺀다 (v1.11.0 앱과 같게) const mode = q.get('mode'); const after = q.get('after') ? Number(q.get('after')) : 0; + // 리플레이 필터 (v1.12.0 앱과 같게): 발로란트 경기만 + const replay = q.get('replay'); + const keepReplay = (x) => (replay === 'yes' || replay === 'no' ? x.game === 'valorant' && hasReplay(x) === (replay === 'yes') : true); const list = db.matches - .filter((x) => (!game || x.game === game) && x.startedAt < before && x.startedAt >= after && keep(x) && x.mode !== '데스매치' && (!mode || x.mode === mode)) + .filter((x) => (!game || x.game === game) && x.startedAt < before && x.startedAt >= after && keep(x) && keepReplay(x) && x.mode !== '데스매치' && (!mode || x.mode === mode)) .sort((a, b) => b.startedAt - a.startedAt) .slice(0, limit) .map(summary); diff --git a/site/web/src/lib/api.ts b/site/web/src/lib/api.ts index 21f3222..e7fae37 100644 --- a/site/web/src/lib/api.ts +++ b/site/web/src/lib/api.ts @@ -44,6 +44,7 @@ export class ApiError extends Error { /** 경기 탭 필터 */ export type MatchHas = 'timeline' | 'voice'; +export type MatchReplay = 'yes' | 'no'; async function request(path: string, init: RequestInit = {}): Promise { let res: Response; @@ -167,7 +168,8 @@ export const api = { ), // has: timeline = 타임라인에 나오는 경기, voice = 목소리가 녹음된 경기 (v1.9.0 앱부터, 예전 앱은 무시하고 다 보냄) // mode · after (v1.11.0 앱부터): 모드 이름("경쟁전") · 이 시각 이후 시작한 경기. 데스매치는 앱이 늘 뺀다 (예전 앱은 사이트가 거름) - matches: (o: { game?: GameType; limit?: number; before?: number; after?: number; has?: MatchHas; mode?: string } = {}) => + // replay (v1.12.0 앱부터): yes = 게임 PC 에 리플레이 파일이 있는 발로란트 경기, no = 없는 발로란트 경기 (예전 앱은 무시하고 다 보냄) + matches: (o: { game?: GameType; limit?: number; before?: number; after?: number; has?: MatchHas; mode?: string; replay?: MatchReplay } = {}) => request(`/api/matches${qs(o)}`), /** 경기 탭 모드 필터 목록 (v1.11.0 앱부터, 예전 앱은 404) */ matchModes: (game?: GameType) => request<{ game: GameType; mode: string; count: number }[]>(`/api/matches/modes${qs({ game })}`), diff --git a/site/web/src/pages/UserPages.tsx b/site/web/src/pages/UserPages.tsx index dde369c..efb90f9 100644 --- a/site/web/src/pages/UserPages.tsx +++ b/site/web/src/pages/UserPages.tsx @@ -1,7 +1,7 @@ import { useEffect, useMemo, useRef, useState } from 'react'; import { Link, useNavigate, useParams } from 'react-router'; import type { GameType, MatchSummary, User, UserProfile } from '@gvr/shared'; -import { api, type MatchHas } from '../lib/api'; +import { api, type MatchHas, type MatchReplay } from '../lib/api'; import { useStatus } from '../store/app'; import { dateInputToMs, dateInputValue, fmtDuration, fmtDay } from '../lib/format'; import { sfx } from '../lib/sfx'; @@ -70,17 +70,19 @@ export function MatchesPage() { const [game, setGameRaw] = useState(null); const [has, setHas] = useState(null); const [mode, setMode] = useState(null); + const [replay, setReplay] = useState(null); // 날짜 (한국 시각): from = 시작 날 0시, to = 끝 날 23:59:59.999 const [from, setFrom] = useState(undefined); const [to, setTo] = useState(undefined); - // 게임을 바꾸면 그 게임에 없을 수 있는 모드는 풀어 준다 + // 게임을 바꾸면 그 게임에 없을 수 있는 모드는 풀어 준다 (리플레이 필터는 발로란트만) const setGame = (g: GameType | null) => { setGameRaw(g); setMode(null); + if (g === 'lol') setReplay(null); }; const nav = useNavigate(); - const query = { limit: PAGE, game: game ?? undefined, has: has ?? undefined, mode: mode ?? undefined, after: from, before: to === undefined ? undefined : to + 1 }; - const { data, err, loading, retry } = useLoad(() => api.matches(query), [game, has, mode, from, to]); + const query = { limit: PAGE, game: game ?? undefined, has: has ?? undefined, mode: mode ?? undefined, replay: replay ?? undefined, after: from, before: to === undefined ? undefined : to + 1 }; + const { data, err, loading, retry } = useLoad(() => api.matches(query), [game, has, mode, replay, from, to]); // 모드 목록: 예전 앱(404)은 불러온 경기에서 만든다 const [modeList, setModeList] = useState<{ mode: string; count: number | null }[] | null>(null); useEffect(() => { @@ -115,11 +117,13 @@ export function MatchesPage() { // 예전 앱은 has · 모드 · 날짜를 모르고 다 보낸다: 여기서도 거른다 if (has === 'voice' && !hasVoice(m)) continue; if (m.mode === HIDDEN_MODE || (mode && m.mode !== mode)) continue; + // 리플레이를 모르는(replay 없음) 예전 앱 경기는 리플레이 필터에서 뺀다 + if (replay && (m.game !== 'valorant' || m.replay !== (replay === 'yes'))) continue; if ((from !== undefined && m.startedAt < from) || (to !== undefined && m.startedAt > to)) continue; out.push(m); } return out; - }, [data, more.list, has, mode, from, to]); + }, [data, more.list, has, mode, replay, from, to]); const modes = useMemo(() => { if (modeList) return modeList; const seen = [...new Set([...(data ?? []), ...more.list].filter((m) => !game || m.game === game).map((m) => m.mode))]; @@ -136,7 +140,9 @@ export function MatchesPage() { .then((r) => gen === moreGen.current && setMore((s) => ({ list: [...s.list, ...r], done: r.length < PAGE, busy: false, err: null }))) .catch((e) => gen === moreGen.current && setMore((s) => ({ ...s, busy: false, err: e }))); }; - const filtered = !!mode || from !== undefined || to !== undefined; + const filtered = !!mode || !!replay || from !== undefined || to !== undefined; + // 예전 앱(v1.11 이하)은 리플레이를 몰라 리플레이 필터가 되지 않는다 + const replayUnknown = !!replay && !!data?.length && data.every((m) => m.replay === undefined); const groups = useMemo(() => { const g = new Map(); for (const m of all) { @@ -183,6 +189,13 @@ export function MatchesPage() { ))} + {game !== 'lol' && ( + + )}
setFrom(dateInputToMs(e.target.value))} aria-label="시작 날짜" /> ~ @@ -193,11 +206,12 @@ export function MatchesPage() { className="link-btn" onClick={() => { setMode(null); + setReplay(null); setFrom(undefined); setTo(undefined); }} > - 모드 · 날짜 초기화 + 필터 초기화 )}
@@ -207,8 +221,10 @@ export function MatchesPage() { {!data && !err && } {data && all.length === 0 && (
- {filtered - ? '고른 모드 · 날짜에 맞는 경기가 없습니다.' + {replayUnknown + ? '리플레이 필터는 게임 PC 앱 v1.12.0 부터 됩니다. 앱을 업데이트해 주세요.' + : filtered + ? '고른 필터에 맞는 경기가 없습니다.' : has === 'voice' ? '목소리가 녹음된 경기가 없습니다.' : has === 'timeline'