Skip to content

[Fix/#232] 통계API수정 - #233

Merged
kimkimgungunwoo merged 1 commit into
developfrom
fix/#232
Aug 3, 2026
Merged

[Fix/#232] 통계API수정#233
kimkimgungunwoo merged 1 commit into
developfrom
fix/#232

Conversation

@kimkimgungunwoo

Copy link
Copy Markdown
Contributor

📌 관련 이슈번호

(Closes 키워드가 있어야 PR이 머지되었을 때 이슈가 자동으로 닫힌다)

📌 PR 유형

어떤 변경 사항이 있나요?

  • 새 기능 추가
  • 버그 수정
  • 리팩토링

📌 PR 요약

해당 PR을 간단하게 요약해 주세요

📌 작업 세부 내용

📸 스크린샷 (선택)

🔗 참고 자료

@kimkimgungunwoo kimkimgungunwoo self-assigned this Aug 3, 2026
@kimkimgungunwoo kimkimgungunwoo linked an issue Aug 3, 2026 that may be closed by this pull request
@coderabbitai

coderabbitai Bot commented Aug 3, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

통계 서비스가 UTC 15시를 KST 자정 경계로 사용하도록 날짜 보정 함수를 추가했습니다. getLastMonth는 시스템 시간대 대신 보정된 날짜를 사용해 이전 달을 계산합니다.

Changes

KST 월간 통계 계산

Layer / File(s) Summary
날짜 보정 및 이전 달 계산
src/stats/stats.service.ts
UTC 15시를 기준으로 KST 날짜를 보정하는 상수와 함수를 추가했습니다. getLastMonth가 보정된 날짜를 사용하도록 변경했습니다.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

  • TEAM-DAILOG/BE#187: src/stats/stats.service.ts의 월간 통계 날짜 계산을 수정한 PR입니다.
🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 inconclusive)

Check name Status Explanation Resolution
Description check ❓ Inconclusive 설명은 이슈 연결과 버그 수정 유형만 포함하며, 구체적인 변경 내용과 결과를 설명하지 않습니다. 통계 API 버그의 원인, 수정 내용, 검증 결과를 PR 설명에 추가하세요.
Linked Issues check ❓ Inconclusive 연결 이슈 #232에 오류, 원인, 해결 방안, 결과가 정의되지 않아 요구사항 충족 여부를 검증할 수 없습니다. 이슈 #232에 구체적인 오류, 해결 조건, 기대 결과를 작성하세요.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed 제목은 이슈 #232와 통계 API 수정이라는 주요 변경 내용을 명확하게 나타냅니다.
Out of Scope Changes check ✅ Passed 변경은 통계 API의 날짜 보정과 이전 달 계산 수정이며, 이슈 #232의 통계 기능 수정 범위와 일치합니다.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ 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 fix/#232

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/stats/stats.service.ts (1)

22-37: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

UTC 15시 경계의 회귀 테스트를 추가하세요.

getKstAdjustedDate()의 경계 조건을 다음 시각으로 검증하세요.

  • 2026-01-31T14:59:59.999Z → KST 2026-01-31, 이전 달 2025-12
  • 2026-01-31T15:00:00.000Z → KST 2026-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

📥 Commits

Reviewing files that changed from the base of the PR and between 1551702 and 898e54b.

📒 Files selected for processing (1)
  • src/stats/stats.service.ts

Comment on lines +140 to +142
// "이번 달"을 오늘의 질문과 동일하게 KST 자정(=UTC 15시) 경계로 판단한 뒤, 하나 전 달을 계산한다.
private getLastMonth(): { year: number; month: number } {
const now = new Date();
const now = getKstAdjustedDate();

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 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' || true

Repository: 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)}`);
  }
}
JS

Repository: 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.

@kimkimgungunwoo
kimkimgungunwoo merged commit 79e6d8e into develop Aug 3, 2026
2 checks passed
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.

[Fix] 통계기능수정

1 participant