관리자 편집 보호: 자동 매칭은 관리자가 정한 영상을 덮어쓰지 않음(쓰기 시점 조건·실제 갱신만 집계), 다시 가져와도 관리자가 정한 장르(빈 선택 포함) 유지, 안 바꾼 유튜브 주소는 보내지 않음 + 후보 확정 버튼, 회귀 테스트 3개·e2e

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
EJClaw
2026-10-18 20:36:27 +09:00
parent 36d3be6880
commit c018bc5a9d
7 changed files with 121 additions and 11 deletions

View File

@@ -62,7 +62,9 @@ export class Catalog {
this.db.query('INSERT OR IGNORE INTO song_artists (song_id, artist_id, role) VALUES (?, ?, ?)').run(id, this.artistId(a.name, a.melonArtistId), 'main');
});
}
for (const g of s.genres ?? []) this.db.query('INSERT OR IGNORE INTO song_genres (song_id, genre_id, source) VALUES (?, ?, ?)').run(id, g, s.source);
// Genres an admin has set (even to none) are final: imports only add genres to songs nobody edited.
const adminGenres = this.db.query<{ g: string | null }, [number]>('SELECT genres_source g FROM songs WHERE id = ?').get(id)?.g === 'admin';
if (!adminGenres) for (const g of s.genres ?? []) this.db.query('INSERT OR IGNORE INTO song_genres (song_id, genre_id, source) VALUES (?, ?, ?)').run(id, g, s.source);
if (s.lyrics) this.db.query('INSERT OR IGNORE INTO lyrics (song_id, text, source, fetched_at) VALUES (?, ?, ?, ?)').run(id, s.lyrics, s.source, now);
this.db.query('INSERT OR IGNORE INTO song_sources (song_id, source, ref) VALUES (?, ?, ?)').run(id, s.source, s.ref);
return [id, created];