Feat/weekly rankings cron#21
Conversation
UFC 공식 랭킹은 매주 화요일(미국)에 한 번 갱신되므로 매일 크롤할 필요가 없어 별도 엔드포인트로 분리하고 일요일 KST 15:00(주 1회) 스케줄로 변경. - src/app/api/cron/rankings/route.ts: 신규 — 랭킹 전용 크론 엔드포인트 - maxDuration=30, Bearer 토큰 검증, revalidate + 페이지 워밍 - vercel.json: 두 번째 크론 항목 추가 (0 6 * * 0 = 일요일 UTC 06:00) - src/app/api/cron/crawl/route.ts: 랭킹 관련 로직 전부 제거 - Phase 1 병렬에서 crawlUfcRankings() 제거 (3→2개) - Phase 2 병렬에서 rankings insert 제거 (4→3개) - results.rankings, /rankings revalidate/워밍 제거 - 일일 크론 실행 시간 추가 단축 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
UFC kr.ufc.com이 일부 챔피언의 img src를 상대 경로(`/s3/files/...`)로, 나머지를 절대 URL(`https://ufc.com/...`)로 섞어 반환. 상대 경로는 브라우저가 사이트 도메인 기준으로 해석해 404가 됨 (예: Sean Strickland 이미지 누락). - normalizeImageUrl() 헬퍼 추가: `new URL(src, UFC_RANKINGS_URL)`로 통일 - 일반 챔피언 + P4P 챔피언 양쪽에 적용 - 정규화 결과 `https://kr.ufc.com/s3/files/...`는 302로 실제 이미지에 리다이렉트되어 정상 표시 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
📝 WalkthroughWalkthrough이 PR은 UFC 랭킹 크롤 작업을 메인 크론 워크플로우에서 분리하여 독립적인 스케줄된 엔드포인트로 이동시킵니다. 랭킹 크롤러에 이미지 URL 정규화 기능을 추가하고, 새로운 Changes랭킹 크론 분리 및 스케줄링
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Possibly related PRs
Poem
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Pull request overview
주간 UFC 랭킹 크롤링을 별도의 Vercel Cron으로 분리해 운영하고, 랭킹 데이터의 이미지 URL 파싱을 안정화하려는 변경입니다. 기존 일일 크론(/api/cron/crawl)에서 랭킹 작업을 제거하고, /api/cron/rankings를 추가해 랭킹 갱신/캐시 무효화/워밍업을 독립적으로 수행합니다.
Changes:
- Vercel Cron에
/api/cron/rankings(주 1회) 스케줄 추가 - 랭킹 크론 API 라우트 신설 및 Supabase 저장 +
/rankings리밸리데이트/워밍업 추가 - 랭킹 크롤러에서 UFC 이미지 src를 절대 URL로 정규화
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| vercel.json | 랭킹 크론 스케줄을 추가해 주간 실행 경로를 마련 |
| src/lib/crawl/rankings-crawler.ts | 이미지 URL을 상대/절대 혼용에도 안전하게 정규화 |
| src/app/api/cron/rankings/route.ts | 랭킹 전용 크론 엔드포인트 추가(저장, 리밸리데이트, 워밍업) |
| src/app/api/cron/crawl/route.ts | 기존 일일 크론에서 랭킹 크롤/저장/리밸리데이트/워밍업을 제거 |
Comments suppressed due to low confidence (1)
src/app/api/cron/crawl/route.ts:179
- 워밍업 fetch에서
NEXT_PUBLIC_SITE_URL을 그대로 사용하면 값에 path가 포함된 경우(예:/ko)${siteUrl}${path}가 잘못된 URL이 됩니다.new URL(siteUrl).origin으로 정규화한 origin에만path를 붙이거나,src/app/layout.tsx의 SITE_URL 정규화 로직과 동일한 유틸을 재사용하도록 수정해 주세요.
const siteUrl = process.env.NEXT_PUBLIC_SITE_URL;
if (siteUrl) {
const pagesToWarm = [
"/",
"/en",
"/predictions",
"/en/predictions",
"/schedule",
"/en/schedule",
];
await Promise.allSettled(
pagesToWarm.map((path) =>
fetch(`${siteUrl}${path}`, { cache: "no-store" })
)
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| const authHeader = request.headers.get("authorization"); | ||
| if (authHeader !== `Bearer ${process.env.CRON_SECRET}`) { |
| await Promise.allSettled([ | ||
| fetch(`${siteUrl}/rankings`, { cache: "no-store" }), | ||
| fetch(`${siteUrl}/en/rankings`, { cache: "no-store" }), |
Summary by CodeRabbit
릴리스 노트