[Feat] : J-POP 곡 한국어 번역 크론 작업 추가 (#186)#187
Conversation
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
/describe |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
/review |
|
/improve |
Code Review by Qodo
|
Code Review by QodoNew Review StartedThis review has been superseded by a new analysisⓘ The new review experience is currently in Beta. Learn more |
Review Summary by QodoAdd J-POP song Korean translation automation with OpenAI integration
WalkthroughsDescription• Add J-POP song Korean translation cron job using OpenAI GPT-4o-mini - Translates Japanese song titles and artist names to Korean - Skips already-translated and non-Japanese songs • Create new database functions for J-POP song retrieval and translation updates • Add GitHub Actions workflow for daily automatic translation execution • Re-enable tagging song cron workflow with updated schedule • Add pnpm trans-jpn script command and documentation Diagramflowchart LR
A["J-POP Songs<br/>tag_id=101"] -->|getJpopSongsForTranslationDB| B["Translation Script<br/>translationJpn.ts"]
B -->|Check Japanese<br/>& Skip Logic| C["OpenAI GPT-4o-mini<br/>translateJpnToKo"]
C -->|title_ko, artist_ko| D["Update Database<br/>updateSongKoTranslationDB"]
E["GitHub Actions<br/>translation_jpn.yml"] -->|Daily 14:00 UTC| B
File Changes1. packages/crawling/src/cron/translationJpn.ts
|
Code Review by Qodo
|
|
PR Description updated to latest commit (c322d51)
|
| export async function getJpopSongsForTranslationDB() { | ||
| const supabase = getClient(); | ||
|
|
||
| const { data, error } = await supabase | ||
| .from('songs') | ||
| .select('id, title, artist, title_ko, artist_ko, song_tags!inner(tag_id)') | ||
| .eq('song_tags.tag_id', 101) | ||
| .limit(50000); | ||
|
|
There was a problem hiding this comment.
1. J-pop query lacks ko filter 📎 Requirement gap ➹ Performance
getJpopSongsForTranslationDB() fetches all J-POP songs by tag without filtering to only rows missing title_ko or artist_ko, then relies on in-script skipping. This violates the requirement to efficiently target only records needing backfill and may cause unnecessary reads/work.
Agent Prompt
## Issue description
`getJpopSongsForTranslationDB()` currently selects all J-POP songs (tag_id=101) and relies on application-side skipping. Compliance requires filtering at the DB query level to only return rows where `title_ko` OR `artist_ko` is missing/empty.
## Issue Context
The cron job should efficiently backfill only needed records; fetching already-translated rows increases read volume and processing time.
## Fix Focus Areas
- packages/crawling/src/supabase/getDB.ts[102-114]
- packages/crawling/src/cron/translationJpn.ts[18-39]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
| console.log('result : ', result); | ||
| // const success = await updateSongKoTranslationDB(song.id, result.title_ko, result.artist_ko); | ||
| // if (success) { | ||
| // resultsLog.success++; | ||
| // console.log(`[OK] ${song.title} → ${result.title_ko} / ${song.artist} → ${result.artist_ko}`); | ||
| // } else { | ||
| // resultsLog.failed++; | ||
| // } |
There was a problem hiding this comment.
2. Translation not persisted 🐞 Bug ≡ Correctness
translationJpn.ts generates translations but never updates songs.title_ko/artist_ko because the DB update call is commented out, so the scheduled workflow does no effective work. This also guarantees resultsLog.success remains 0, making the job output misleading.
Agent Prompt
### Issue description
`packages/crawling/src/cron/translationJpn.ts` computes a translation result but never writes it to Supabase because the update logic is commented out.
### Issue Context
- The workflow `.github/workflows/translation_jpn.yml` runs `pnpm run trans-jpn` daily.
- `updateSongKoTranslationDB()` already exists and returns `true/false`.
### Fix Focus Areas
- packages/crawling/src/cron/translationJpn.ts[50-57]
- packages/crawling/src/supabase/updateDB.ts[44-58]
### What to change
- Uncomment (or re-implement) the `updateSongKoTranslationDB(song.id, ...)` call.
- Increment `resultsLog.success` on successful update, and `resultsLog.failed` otherwise.
- Ensure the final summary reflects actual counts.
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
| if (!result) { | ||
| resultsLog.failed++; | ||
| console.log(`[FAIL] ${song.title} - ${song.artist}: 번역 실패`); | ||
| continue; | ||
| } | ||
|
|
||
| console.log('result : ', result); | ||
| // const success = await updateSongKoTranslationDB(song.id, result.title_ko, result.artist_ko); | ||
| // if (success) { | ||
| // resultsLog.success++; | ||
| // console.log(`[OK] ${song.title} → ${result.title_ko} / ${song.artist} → ${result.artist_ko}`); | ||
| // } else { | ||
| // resultsLog.failed++; | ||
| // } | ||
| } catch (error) { | ||
| resultsLog.failed++; | ||
| console.error(`[ERROR] ${song.title} - ${song.artist}:`, error); | ||
| } | ||
|
|
||
| processedCount++; | ||
|
|
||
| // OpenAI rate limit 대비 딜레이 | ||
| await new Promise(resolve => setTimeout(resolve, 200)); | ||
| } |
There was a problem hiding this comment.
3. Delay/cap bypass on failure 🐞 Bug ☼ Reliability
When translateJpnToKo returns null, the loop continues before processedCount++ and the 200ms delay, so both the 5,000-item cap and rate-limit protection are skipped for failures. This can cause the job to hammer OpenAI rapidly and exceed intended per-run limits.
Agent Prompt
### Issue description
On `!result`, the code `continue`s before `processedCount++` and the 200ms delay, bypassing both the per-run limit and throttling on failure.
### Issue Context
This job calls OpenAI and should throttle consistently regardless of success/failure to avoid rate limits and unexpected cost.
### Fix Focus Areas
- packages/crawling/src/cron/translationJpn.ts[41-48]
- packages/crawling/src/cron/translationJpn.ts[63-67]
### What to change
- Restructure the loop so that **every OpenAI attempt** increments `processedCount` and awaits the delay.
- Example: move `processedCount++` and the delay into a `finally` block that runs for all non-skip paths.
- Alternatively: increment/count and delay immediately after the OpenAI call, before any `continue`.
- Keep skip paths (already-translated / no-Japanese) fast (no delay) if desired, but ensure failure paths are throttled.
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
| console.log('result : ', result); | ||
| // const success = await updateSongKoTranslationDB(song.id, result.title_ko, result.artist_ko); | ||
| // if (success) { | ||
| // resultsLog.success++; | ||
| // console.log(`[OK] ${song.title} → ${result.title_ko} / ${song.artist} → ${result.artist_ko}`); | ||
| // } else { | ||
| // resultsLog.failed++; | ||
| // } |
There was a problem hiding this comment.
1. translationjpn.ts doesn’t update db 📎 Requirement gap ≡ Correctness
The new translation cron computes Korean translations but never persists them because the DB update call is commented out. This fails the requirement to write translated values back to songs.title_ko/songs.artist_ko.
Agent Prompt
## Issue description
`translationJpn.ts` translates titles/artists but does not write results back to Supabase because `updateSongKoTranslationDB(...)` is commented out.
## Issue Context
Compliance requires the script to persist translated values into `songs.title_ko` and `songs.artist_ko`.
## Fix Focus Areas
- packages/crawling/src/cron/translationJpn.ts[41-57]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
User description
📌 PR 제목
[Feat] : J-POP 곡 한국어 번역 크론 작업 추가
📌 변경 사항
translationJpn.ts,translateJpnToKo.ts)getJpopSongsForTranslationDB(): tag_id=101(J-POP) 곡 조회updateSongKoTranslationDB(): title_ko, artist_ko 업데이트translation_jpn.yml): 매일 자동 실행tagging_song.yml)pnpm trans-jpn스크립트 명령어 추가💬 추가 참고 사항
PR Type
Enhancement
Description
Add J-POP song Korean translation cron job using OpenAI GPT-4o-mini
Implement database functions for querying and updating song translations
Create GitHub Actions workflow for daily automatic translation execution
Re-enable tagging songs workflow with updated schedule
Add
pnpm trans-jpnscript command and documentationDiagram Walkthrough
File Walkthrough
4 files
New J-POP song translation cron scriptOpenAI-based Japanese to Korean translation utilityAdd J-POP songs query function for translationAdd Korean translation update database function3 files
New GitHub Actions workflow for J-POP translationRe-enable tagging workflow with updated scheduleAdd trans-jpn npm script command2 files
Remove test comment from tagging scriptUpdate sitemap timestamp1 files
Update documentation with translation workflow info1 files
Reorder import statements for consistency