관리자 "원곡 찾기" 화면: 유튜브 원곡 찾기 결과를 확정·후보·못 찾음·원곡 없음·재생 불가·아직 안 찾음 탭으로(방금 처리된 곡이 위), 진행률·끝 예상·이번 작업 결과, 5초 자동 새로고침(보고 있을 때만, 목록 위에서는 멈춤), 줄에서 바로 확정 + 패널에서 미리듣기·다른 후보·주소 붙여넣기·확정 취소(관리자 후보로, 게임에서 빠지고 자동 확정 안 됨)·원곡 없음 표시·다시 찾기, 처리하면 다음 곡으로. 저장은 기존 경로, 감사 로그 기록

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
EJClaw
2026-10-19 21:47:10 +09:00
parent c4edccf352
commit 8d4e32d737
11 changed files with 760 additions and 5 deletions

View File

@@ -25,6 +25,7 @@ import {
type BulkAction,
} from '../songs/admin-ops';
import { updateSong } from '../songs/store';
import { REVIEW_TABS, markNoOriginal, reviewCounts, reviewJob, reviewList, unconfirmVideo, type ReviewTab } from '../songs/youtube-review';
type Env = { Variables: { userId: string | null; role: Role } };
@@ -193,6 +194,33 @@ export function mountCatalogAdmin(
return c.json({ merged: n });
});
// ------------------------------------------------------------ 원곡 찾기 (matcher results, checked while it runs)
// Choosing a video goes through PATCH /songs/:id { youtube } and 다시 찾기 through /songs/bulk { action: 'rematch' }.
app.get('/youtube', (c) => {
const t = c.req.query('tab');
const tab: ReviewTab = (REVIEW_TABS as readonly string[]).includes(t ?? '') ? (t as ReviewTab) : 'candidate';
const list = reviewList(d.db, tab, { q: c.req.query('q')?.trim().slice(0, 100) || undefined, page: Number(c.req.query('page') ?? 0) || 0 });
return c.json({ tab, counts: reviewCounts(d.db), job: reviewJob(d.db), ...list });
});
/** The video before an admin change, for the 기록. */
const videoOf = (id: number) => d.db.query<{ youtube_id: string | null; youtube_status: string; youtube_source: string | null }, [number]>('SELECT youtube_id, youtube_status, youtube_source FROM songs WHERE id = ?').get(id);
app.post('/youtube/:id/unconfirm', (c) => {
const id = Number(c.req.param('id'));
const before = videoOf(id);
if (!unconfirmVideo(d.db, id)) return c.json({ error: '확정된 영상이 있는 노래가 아니에요.' }, 400);
d.audit.log(h.actor(c), 'song.youtube.unconfirm', String(id), before, null);
changed();
return c.json({ ok: true });
});
app.post('/youtube/:id/no-original', (c) => {
const id = Number(c.req.param('id'));
const before = videoOf(id);
if (!markNoOriginal(d.db, id)) return c.json({ error: '노래를 찾을 수 없어요.' }, 404);
d.audit.log(h.actor(c), 'song.youtube.none', String(id), before, null);
changed();
return c.json({ ok: true });
});
// ------------------------------------------------------------ artists (가수 별칭)
app.get('/artists', (c) => c.json(listArtists(d.db, (c.req.query('q') ?? '').trim().slice(0, 60), Number(c.req.query('page') ?? 0) || 0)));
app.patch('/artists/:id', async (c) => {