Skip to content

Comments

fix(api): AI 파싱 타임존 미적용 버그 수정 및 date-fns 제거 (#220)#221

Merged
dydals3440 merged 2 commits intomainfrom
fix/ai-parse-timezone
Feb 24, 2026
Merged

fix(api): AI 파싱 타임존 미적용 버그 수정 및 date-fns 제거 (#220)#221
dydals3440 merged 2 commits intomainfrom
fix/ai-parse-timezone

Conversation

@dydals3440
Copy link
Contributor

📋 개요

AI 자연어 파싱 시 서버 UTC 시간을 사용하여 사용자 타임존과 최대 9시간 차이가 발생하는 버그를 수정하고, date-fns 의존성을 제거하여 dayjs로 통일합니다.

🏷️ 변경 유형

  • 🐛 fix - 버그 수정
  • ♻️ refactor - 코드 리팩토링 (date-fns → dayjs)

📦 영향 범위

  • apps/api - NestJS 백엔드

📝 변경 내용

핵심 수정

  • buildParseTodoPrompttimezone 파라미터 추가 → 사용자 로컬 시간으로 프롬프트 생성
  • date-fnsdayjs + timezone/utc 플러그인 + ko locale로 교체
  • AiService.parseTodo 시그니처에 timezone 인자 추가
  • AiController@Timezone() 데코레이터 + @ApiHeader(X-Timezone) 추가

의존성 정리

  • date-fns 의존성 완전 제거 (1곳에서만 사용 중이었음)
  • 프로젝트 전체 날짜 라이브러리를 dayjs로 통일

테스트

  • 신규: parse-todo.prompt.spec.ts (11건) - 타임존 변환, 한국어 요일, 프롬프트 구조 검증
  • 수정: ai.service.spec.ts (26건), ai.controller.spec.ts (3건)
  • 수정: ai.integration-spec.ts (9건, UTC 폴백 테스트 추가)
  • 수정: ai.e2e-spec.ts (24건, 타임존 처리 섹션 추가)

🧪 테스트

테스트 방법

# 프롬프트 단위 테스트
npx jest --testPathPattern="prompts/parse-todo"

# 서비스/컨트롤러 단위 테스트
npx jest --testPathPattern="ai\.(service|controller)\.spec"

# 통합 테스트
npx jest --config ./test/jest-integration.json --testPathPattern="ai\.integration-spec"

# E2E 테스트
npx jest --config ./test/jest-e2e.json --testPathPattern="ai\.e2e-spec"

테스트 결과

  • 단위 테스트 통과 (40/40)
  • 통합 테스트 통과 (9/9)
  • E2E 테스트 통과 (24/24)
  • TypeScript typecheck 통과
  • Biome lint 통과

✅ 체크리스트

작성자 확인

  • 코드가 프로젝트의 코딩 컨벤션을 따릅니다
  • pnpm check (Biome) 검사를 통과했습니다
  • 모든 테스트가 통과합니다 (pnpm test)
  • 커밋 메시지가 Conventional Commits 규칙을 따릅니다
  • date-fns 참조가 apps/api/src/에서 완전 제거됨을 확인

🔗 관련 이슈

Closes #220

- buildParseTodoPrompt에 timezone 파라미터 추가하여 사용자 로컬 시간 반영
- date-fns → dayjs 교체로 날짜 라이브러리 통일
- Controller에 @Timezone() 데코레이터 + @ApiHeader 추가
- 전체 테스트 수정: unit/integration/E2E (신규 prompt spec 11건 포함)
@dydals3440 dydals3440 added type: fix 🐛 버그 수정 - 사용자 이탈을 방지하고 시스템 안정성을 확보하는 작업 scope: api 🌐 API - NestJS 서버 로직, DB 스키마 및 백엔드 인프라 관련 status: needs review 🔍 리뷰 대기 - 작업 완료 후 병목 제거를 위해 팀원의 빠른 피드백이 필요한 상태 labels Feb 24, 2026
@dydals3440 dydals3440 self-assigned this Feb 24, 2026
@dydals3440 dydals3440 requested a review from hijjoy February 24, 2026 21:36
@gemini-code-assist
Copy link

Summary of Changes

Hello @dydals3440, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

이 PR은 AI 자연어 파싱 기능에서 발생하던 타임존 관련 버그를 수정하고, 날짜/시간 처리 라이브러리를 date-fns에서 dayjs로 일원화하는 것을 목표로 합니다. 사용자 타임존을 정확히 반영하여 AI 파싱 결과의 정확성을 높이고, 불필요한 의존성을 제거하여 코드 베이스를 간소화했습니다.

Highlights

  • AI 파싱 타임존 버그 수정: AI 자연어 파싱 시 서버 UTC 시간을 사용하여 사용자 타임존과 최대 9시간 차이가 발생하던 버그를 수정하여, 사용자 로컬 시간을 정확히 반영하도록 개선했습니다.
  • 날짜/시간 라이브러리 통일: date-fns 의존성을 완전히 제거하고 dayjs 및 관련 플러그인으로 날짜/시간 처리 라이브러리를 통일하여 코드 베이스를 간소화했습니다.
  • X-Timezone 헤더 지원: AiControllerX-Timezone HTTP 헤더를 통해 사용자 타임존을 전달받는 기능을 추가하여 API 요청 시 타임존 정보를 활용할 수 있도록 했습니다.
  • 프롬프트 생성 로직 개선: buildParseTodoPrompt 함수가 사용자 타임존을 파라미터로 받아 현재 시간을 해당 타임존에 맞춰 프롬프트에 포함하도록 변경되었습니다.
  • 테스트 강화: 타임존 변환, 한국어 요일 포맷, 프롬프트 구조 등을 검증하는 새로운 단위 테스트가 추가되었으며, 기존 AI 관련 테스트들이 타임존 처리 로직을 포함하도록 업데이트되었습니다.
Changelog
  • apps/api/package.json
    • date-fns 의존성이 제거되었습니다.
    • dayjs 관련 플러그인 (timezone, utc)이 추가되었습니다.
  • apps/api/src/modules/ai/ai.controller.spec.ts
    • AI 컨트롤러의 parseTodo 메서드 테스트에서 timezone 인자가 추가되었습니다.
  • apps/api/src/modules/ai/ai.controller.ts
    • X-Timezone HTTP 헤더를 처리하는 @Timezone() 데코레이터와 ApiHeader 데코레이터가 추가되었습니다.
    • parseTodo 메서드 시그니처가 업데이트되었습니다.
  • apps/api/src/modules/ai/ai.service.spec.ts
    • AI 서비스의 parseTodo 메서드 테스트에서 timezone 인자가 추가되었습니다.
    • 타임존이 프롬프트에 올바르게 반영되는지 확인하는 테스트 케이스가 추가되었습니다.
  • apps/api/src/modules/ai/ai.service.ts
    • parseTodo 메서드 시그니처에 timezone 매개변수가 추가되었습니다.
    • buildParseTodoPrompt 호출 시 해당 timezone을 전달하도록 수정되었습니다.
  • apps/api/src/modules/ai/prompts/parse-todo.prompt.spec.ts
    • buildParseTodoPrompt 함수에 대한 새로운 단위 테스트 파일이 추가되어 타임존 변환, 한국어 요일 포맷, 프롬프트 구조 및 기본값 처리 등을 검증합니다.
  • apps/api/src/modules/ai/prompts/parse-todo.prompt.ts
    • date-fns 대신 dayjsdayjs/plugin/timezone, dayjs/plugin/utc를 사용하도록 변경되었습니다.
    • buildParseTodoPrompt 함수가 timezone 인자를 받아 현재 시간을 해당 타임존에 맞춰 포맷하도록 수정되었습니다.
  • apps/api/test/e2e/ai.e2e-spec.ts
    • AI 파싱 E2E 테스트에서 X-Timezone 헤더를 포함하도록 요청이 수정되었습니다.
    • 타임존 처리 관련 새로운 E2E 테스트 섹션이 추가되었습니다.
  • apps/api/test/integration/ai.integration-spec.ts
    • AI 컨트롤러 통합 테스트에서 X-Timezone 헤더를 포함하도록 요청이 수정되었습니다.
    • aiService.parseTodo 호출 시 timezone 인자가 전달되는지 확인하는 로직이 추가되었습니다.
    • X-Timezone 헤더가 없을 때 UTC가 기본값으로 사용되는 테스트가 추가되었습니다.
  • pnpm-lock.yaml
    • date-fns 관련 항목이 제거되었습니다.
    • babel-jestts-jest@babel/core 버전이 업데이트되었습니다.
Activity
  • AI 파싱 시 타임존 미적용 버그 수정 및 date-fns 제거를 목표로 PR이 생성되었습니다.
  • apps/api 모듈의 package.json에서 date-fns 의존성이 제거되었습니다.
  • ai.controller.tsX-Timezone 헤더를 처리하는 로직이 추가되었습니다.
  • ai.service.tsparseTodo 메서드 시그니처가 timezone 인자를 받도록 변경되었습니다.
  • parse-todo.prompt.ts에서 date-fnsdayjs로 교체되었고, 타임존 처리가 구현되었습니다.
  • ai.controller.spec.ts, ai.service.spec.ts, ai.e2e-spec.ts, ai.integration-spec.ts 등 관련 테스트 파일들이 업데이트되었습니다.
  • parse-todo.prompt.spec.ts라는 새로운 단위 테스트 파일이 추가되어 타임존 변환 및 프롬프트 구조를 검증합니다.
  • 모든 단위, 통합, E2E 테스트가 성공적으로 통과되었습니다.
  • TypeScript 타입 체크 및 Biome 린트 검사가 통과되었습니다.
  • date-fns 참조가 apps/api/src/에서 완전히 제거되었음이 확인되었습니다.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

AI 파싱 기능의 타임존 버그를 사용자의 타임존을 반영하여 성공적으로 수정하셨습니다. 또한 date-fns를 제거하고 dayjs로 날짜/시간 라이브러리를 통일하여 프로젝트의 일관성과 유지보수성을 높인 점이 훌륭합니다. 단위, 통합, E2E 테스트를 포괄적으로 추가하여 수정 사항의 신뢰성을 확보한 점도 인상적입니다. dayjs 플러그인 설정 방식에 대해 코드 구조를 더욱 개선할 수 있는 한 가지 제안 사항이 있습니다.

InMemoryReminderSchedulerAdapter와 TodoReminderJob 간 race condition으로
동일 todo+stage 알림이 2번 발송되는 버그를 ILockProvider 기반 dedup으로 수정.
dayjs 플러그인(utc/timezone) 초기화를 dayjs.setup.ts로 중앙화하여 각 파일의
중복 extend 호출 제거.
@dydals3440 dydals3440 merged commit 6e91977 into main Feb 24, 2026
3 checks passed
@dydals3440 dydals3440 deleted the fix/ai-parse-timezone branch February 24, 2026 22:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope: api 🌐 API - NestJS 서버 로직, DB 스키마 및 백엔드 인프라 관련 status: needs review 🔍 리뷰 대기 - 작업 완료 후 병목 제거를 위해 팀원의 빠른 피드백이 필요한 상태 type: fix 🐛 버그 수정 - 사용자 이탈을 방지하고 시스템 안정성을 확보하는 작업

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: AI 파싱 타임존 미적용으로 인한 날짜 오류 + date-fns 제거

1 participant