[Fix/#232] 통계API수정 - #233
Conversation
Walkthrough통계 서비스가 UTC 15시를 KST 자정 경계로 사용하도록 날짜 보정 함수를 추가했습니다. ChangesKST 월간 통계 계산
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 inconclusive)
✅ Passed checks (3 passed)
✨ 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.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/stats/stats.service.ts (1)
22-37: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winUTC 15시 경계의 회귀 테스트를 추가하세요.
getKstAdjustedDate()의 경계 조건을 다음 시각으로 검증하세요.
2026-01-31T14:59:59.999Z→ KST2026-01-31, 이전 달2025-122026-01-31T15:00:00.000Z→ KST2026-02-01, 이전 달2026-01연말 전환과 서버
TZ가 달라도 같은 결과가 나오는지 확인하세요.getLastMonth()는 현재 시각을 직접 생성하므로 fake timer 또는 시각 주입을 사용하세요.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/stats/stats.service.ts` around lines 22 - 37, 추가 회귀 테스트에서 getKstAdjustedDate()와 getLastMonth()를 fake timer 또는 주입한 시각으로 검증하세요. 2026-01-31T14:59:59.999Z는 KST 2026-01-31 및 이전 달 2025-12로, 15:00:00.000Z는 KST 2026-02-01 및 이전 달 2026-01로 평가되어야 합니다. 연말 전환과 서버 TZ 설정에 영향을 받지 않도록 UTC 기준 결과를 확인하세요.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/stats/stats.service.ts`:
- Around line 140-142: Update getMonthRange() so its default year and month are
derived from getKstAdjustedDate() instead of the UTC current date, keeping
getScheduleDetail(), getPendingStats(), and getCompletedStats() aligned with
getLastMonth(). Document this KST-based default in the related DTO and Swagger
definitions.
---
Nitpick comments:
In `@src/stats/stats.service.ts`:
- Around line 22-37: 추가 회귀 테스트에서 getKstAdjustedDate()와 getLastMonth()를 fake
timer 또는 주입한 시각으로 검증하세요. 2026-01-31T14:59:59.999Z는 KST 2026-01-31 및 이전 달
2025-12로, 15:00:00.000Z는 KST 2026-02-01 및 이전 달 2026-01로 평가되어야 합니다. 연말 전환과 서버 TZ
설정에 영향을 받지 않도록 UTC 기준 결과를 확인하세요.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: cf482d5c-4eff-417d-98e9-c69089eb07c1
📒 Files selected for processing (1)
src/stats/stats.service.ts
| // "이번 달"을 오늘의 질문과 동일하게 KST 자정(=UTC 15시) 경계로 판단한 뒤, 하나 전 달을 계산한다. | ||
| private getLastMonth(): { year: number; month: number } { | ||
| const now = new Date(); | ||
| const now = getKstAdjustedDate(); |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# 통계 API의 날짜 계산 호출 경로를 확인한다.
rg -n -C 5 \
'getMainStats|getScheduleDetail|getPendingStats|getCompletedStats|getMonthRange|getLastMonth' \
src --glob '*.ts'
# 날짜 경계 관련 테스트를 확인한다.
rg -n -C 5 \
'KST_MIDNIGHT_UTC_HOUR|setSystemTime|15:00|lastMonth|targetMonth' \
src --glob '*spec.ts' --glob '*test.ts' || trueRepository: TEAM-DAILOG/BE
Length of output: 8813
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# 관련 함수와 DTO의 명세 범위를 확인합니다.
sed -n '1,280p' src/stats/stats.service.ts
echo '--- stat query ---'
fd -a 'stats.*dto.*\.ts|.*stats.*\.dto\.ts' src | sed 's#^\./##'
rg -n -C 8 'StatsMonthQueryDto|targetYear|targetMonth|getMonthRange|getKstAdjustedDate|KST' src --glob '*.ts'
# 날짜 경계에서 기본월 기준과 이월 월별 조회가 어떻게 달라지는지 읽기 전용으로 계산합니다.
node - <<'JS'
const zones = [
{ offsetMinutes: 0, label: 'UTC' },
{ offsetMinutes: 540, label: 'KST' },
];
for (const iso of ['2026-02-28T15:00:00Z', '2026-02-28T14:59:59.999Z']) {
const date = new Date(iso);
console.log(`input=${iso}`);
for (const {offsetMinutes, label} of zones) {
const utcYear = date.getUTCFullYear();
const utcMonth = date.getUTCMonth(); // getMonthRange default
const ksOffsetMs = offsetMinutes * 60 * 1000;
const now = new Date(date.getTime() + ksOffsetMs);
const kstMonth = now.getUTCMonth();
const lastMonthDate = new Date(Date.UTC(now.getUTCFullYear(), kstMonth - 1, 1));
console.log(`${label}: utcMonth=${utcMonth+1}; kstAdjustedMonth=${kstMonth+1}; lastMonth=${kstMonth}; lastMonthDate=${lastMonthDate.toISOString().slice(0,10)}`);
}
}
JSRepository: TEAM-DAILOG/BE
Length of output: 39347
월간 통계를 KST 기준으로 동기화하세요.
getLastMonth()는 KST 자정(UTC 15시) 기준으로 계산하지만, getScheduleDetail(), getPendingStats(), getCompletedStats()의 기본 조회는 getMonthRange()에서 UTC 현재 월을 사용합니다. 오늘 질문/KST 일관성이 필요하면 getMonthRange() 기본값도 getKstAdjustedDate() 기준으로 계산하세요. KST 기준이 의도라면 getMonthRange()의 변경된 기본값을 DTO/Swagger 문서화에 명시하세요.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/stats/stats.service.ts` around lines 140 - 142, Update getMonthRange() so
its default year and month are derived from getKstAdjustedDate() instead of the
UTC current date, keeping getScheduleDetail(), getPendingStats(), and
getCompletedStats() aligned with getLastMonth(). Document this KST-based default
in the related DTO and Swagger definitions.
📌 관련 이슈번호
(Closes 키워드가 있어야 PR이 머지되었을 때 이슈가 자동으로 닫힌다)
📌 PR 유형
어떤 변경 사항이 있나요?
📌 PR 요약
해당 PR을 간단하게 요약해 주세요
📌 작업 세부 내용
📸 스크린샷 (선택)
🔗 참고 자료