crawling 미사용 코드 정리 및 다중 카테고리 태깅 리팩토링#194
Conversation
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Review Summary by QodoClean up unused crawling code and add multi-category song tagging
WalkthroughsDescription• Deleted 7 unused crawling scripts and utilities - Removed crawlWiki.ts, replaceSupabaseFailed.ts, postScrapeSongs.ts, updateJpnSongs.ts - Removed transChatGPT.ts, logData.ts, namuArgList.ts • Added multi-category auto-tagging function for songs - Supports language (1), genre (1), and origin (1-3) tags - Implements LLM-based classification with artist tag reuse optimization Diagramflowchart LR
A["Unused Crawling Scripts"] -->|Delete| B["Cleaned Codebase"]
C["Song Metadata"] -->|Process| D["getSongFullTag.ts"]
D -->|AI Classification| E["Language/Genre/Origin Tags"]
D -->|Reuse Existing| F["Artist Tag Cache"]
File Changes1. packages/crawling/src/crawling/crawlWiki.ts
|
Code Review by Qodo
|
| const language = tagIds.find(id => isValidTagId(id, LANGUAGE_TAG_MIN, LANGUAGE_TAG_MAX)); | ||
| const genre = tagIds.find(id => isValidTagId(id, GENRE_TAG_MIN, GENRE_TAG_MAX)); | ||
| const origin = tagIds.filter(id => isValidTagId(id, ORIGIN_TAG_MIN, ORIGIN_TAG_MAX)); | ||
|
|
||
| // 세 카테고리 모두 있어야 재사용 | ||
| if (language && genre && origin.length > 0) { | ||
| return [language, genre, ...origin]; | ||
| } |
There was a problem hiding this comment.
1. getexistingartisttags() returns too many origins 📎 Requirement gap ≡ Correctness
When reusing an artist’s existing tags, the function returns all origin tags without enforcing the required 1–3 origin tag limit. This can violate the tagging cardinality requirements and produce invalid outputs for downstream consumers.
Agent Prompt
## Issue description
`getExistingArtistTags()` reuses existing artist tags but can return more than 3 origin tags, violating the required origin cardinality (1–3).
## Issue Context
Compliance requires: language exactly 1 (100–199), genre exactly 1 (200–299), origin 1–3 (300–399). The LLM path already caps origins via `slice(0, 3)`, but the reuse path does not.
## Fix Focus Areas
- packages/crawling/src/utils/getSongFullTag.ts[74-81]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
| export const autoTagSong = async ( | ||
| title: string, | ||
| artist: string, | ||
| tagsPrompt: string, | ||
| ): Promise<number[] | null> => { | ||
| try { | ||
| if (!tagsPrompt) return null; | ||
|
|
||
| // 1단계: 같은 아티스트의 기존 태그가 모두 있으면 재사용 (API 호출 생략) | ||
| const existingTags = await getExistingArtistTags(artist); | ||
| if (existingTags) return existingTags; | ||
|
|
||
| // 2단계: 한글/가나 감지로 언어 태그만 사전 결정 | ||
| const titleAndArtist = title + artist; | ||
| const hasHangul = /[ㄱ-ㅎㅏ-ㅣ가-힣]/.test(titleAndArtist); | ||
| const hasKana = /[ぁ-んァ-ヶ]/.test(titleAndArtist); | ||
| const knownLanguageTag = hasHangul ? TAG_KOREAN : hasKana ? TAG_JAPANESE : undefined; | ||
|
|
||
| // 3단계: LLM으로 genre + origin (+ 필요 시 language) 판별 | ||
| return await getTagsFromLLM(title, artist, tagsPrompt, knownLanguageTag); |
There was a problem hiding this comment.
2. Conflicting autotagsong apis 🐞 Bug ⚙ Maintainability
새 파일은 autoTagSong(): Promise<number[] | null>을 export 하는데, 기존 워크플로우는 `autoTagSong(): Promise<number | null>`를 전제로 동작합니다. 동일한 export 이름이 공존해 잘못 import하면 런타임/타입 불일치가 발생하고, 현재 tag-songs 크론은 여전히 단일 태그만 저장해 다중 태깅 리팩토링이 적용되지 않습니다.
Agent Prompt
## Issue description
다중 태깅용 `autoTagSong()`(number[] 반환)과 기존 단일 태깅용 `autoTagSong()`(number 반환)이 공존하며 export 이름이 동일합니다. 현재 크론은 단일 태그 삽입만 수행하므로 다중 태깅 리팩토링이 실제로 적용되지 않고, 추후 import 실수 시 타입/런타임 불일치가 발생합니다.
## Issue Context
`postSongTagsDB(songId, tagIds)`는 원래부터 다중 tagIds 삽입을 지원합니다.
## Fix Focus Areas
- packages/crawling/src/utils/getSongFullTag.ts[147-166]
- packages/crawling/src/cron/taggingSongs.ts[1-4]
- packages/crawling/src/cron/taggingSongs.ts[29-41]
## Suggested change
- 크론이 다중 태깅을 의도한다면 import를 `getSongFullTag`로 변경하고, 반환된 `number[]`를 그대로 `postSongTagsDB(song.id, tagIds)`에 전달하세요.
- 다중 태깅을 아직 사용하지 않을 계획이라면, 새 모듈의 export 이름을 명확히 구분(예: `autoTagSongFull`)하거나 기존 `getSongTag.ts`를 대체/삭제해 API 충돌 가능성을 제거하세요.
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
Summary
getSongFullTag.ts추가 (language 1개 + genre 1개 + origin 1~3개)삭제된 파일
src/postScrapeSongs.ts,src/updateJpnSongs.tssrc/crawling/crawlWiki.ts,src/crawling/replaceSupabaseFailed.tssrc/utils/transChatGPT.ts,src/utils/logData.ts,src/utils/namuArgList.tsTest plan
pnpm lint통과 확인getSongFullTag.ts수동 실행 테스트Closes #193
🤖 Generated with Claude Code