Skip to content

Feat/weekly rankings cron#21

Merged
umsungjun merged 2 commits into
mainfrom
feat/weekly-rankings-cron
May 12, 2026
Merged

Feat/weekly rankings cron#21
umsungjun merged 2 commits into
mainfrom
feat/weekly-rankings-cron

Conversation

@umsungjun
Copy link
Copy Markdown
Owner

@umsungjun umsungjun commented May 12, 2026

Summary by CodeRabbit

릴리스 노트

  • 개선 사항
    • UFC 랭킹 데이터 업데이트 프로세스를 독립적인 워크플로우로 분리했습니다.
    • 매주 일요일 오전에 자동으로 실행되도록 스케줄되었습니다.
    • 랭킹 이미지 URL 처리를 개선하여 더 안정적인 이미지 로딩을 제공합니다.

Review Change Stack

umsungjun and others added 2 commits May 12, 2026 21:33
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>
Copilot AI review requested due to automatic review settings May 12, 2026 12:36
@vercel
Copy link
Copy Markdown

vercel Bot commented May 12, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
lets-ko Ready Ready Preview, Comment May 12, 2026 0:36am

@umsungjun umsungjun merged commit 8f81932 into main May 12, 2026
3 of 4 checks passed
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 12, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 03cab761-b750-425d-aea5-14bc680a4ae4

📥 Commits

Reviewing files that changed from the base of the PR and between 4fead11 and cff8703.

📒 Files selected for processing (4)
  • src/app/api/cron/crawl/route.ts
  • src/app/api/cron/rankings/route.ts
  • src/lib/crawl/rankings-crawler.ts
  • vercel.json

📝 Walkthrough

Walkthrough

이 PR은 UFC 랭킹 크롤 작업을 메인 크론 워크플로우에서 분리하여 독립적인 스케줄된 엔드포인트로 이동시킵니다. 랭킹 크롤러에 이미지 URL 정규화 기능을 추가하고, 새로운 /api/cron/rankings 라우트를 생성하며, 메인 크롤 라우트에서 랭킹 관련 작업을 제거합니다.

Changes

랭킹 크론 분리 및 스케줄링

Layer / File(s) Summary
랭킹 크롤러 이미지 URL 정규화
src/lib/crawl/rankings-crawler.ts
normalizeImageUrl() 헬퍼 함수가 UFC 랭킹 소스의 상대/절대 이미지 URL을 절대 URL로 변환하고, 잘못된 입력 시 빈 문자열을 반환합니다. 챔피언 이미지 추출 로직이 이 정규화를 사용하도록 업데이트됩니다.
새로운 랭킹 크론 라우트
src/app/api/cron/rankings/route.ts
Bearer 토큰 인증을 검증하고, crawlUfcRankings()을 통해 랭킹을 크롤링하며, ufc_rankings 테이블에 삽입하고, 랭킹 페이지를 재검증하고, 캐시 무효화 요청을 수행하며, 성공 또는 오류 JSON 응답을 반환하는 /api/cron/rankings 엔드포인트를 생성합니다.
메인 크롤 라우트 리팩토링 및 크론 스케줄링
src/app/api/cron/crawl/route.ts, vercel.json
메인 크롤 라우트에서 랭킹 크롤 작업, 캐시 재검증, 페이지 워밍 목록을 제거합니다. Vercel 설정에 매주 일요일에 실행되는 /api/cron/rankings 크론 작업을 추가합니다.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

  • umsungjun/lets-ko#19: 두 PR 모두 src/app/api/cron/crawl/route.ts의 크론 크롤 플로우를 수정하며(하나는 랭킹을 별도 경로로 분리하고 다른 하나는 crawlUfcRankings를 포함한 크롤을 병렬화함), 밀접하게 관련되어 있습니다.

Poem

🐰 일요일 새벽, 랭킹이 솔로 춤을 춰,
메인 크롤과 작별하고 독립하네,
이미지는 절대 경로로 단장하고,
매주 정각에 스케줄로 춤춘다,
UFC 맞춤형 크론, 이제 깔끔해! ✨

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/weekly-rankings-cron

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +18 to +19
const authHeader = request.headers.get("authorization");
if (authHeader !== `Bearer ${process.env.CRON_SECRET}`) {
Comment on lines +37 to +39
await Promise.allSettled([
fetch(`${siteUrl}/rankings`, { cache: "no-store" }),
fetch(`${siteUrl}/en/rankings`, { cache: "no-store" }),
@coderabbitai coderabbitai Bot mentioned this pull request May 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants