Skip to content

[Refactor] 식단 조회 책임 및 그룹화 구조 개선 - #79

Merged
JangDongHo merged 6 commits into
devfrom
refactor/#78
May 3, 2026
Merged

JangDongHo merged 6 commits into
devfrom
refactor/#78

Conversation

@JangDongHo

@JangDongHo JangDongHo commented May 2, 2026 •

Copy link
Copy Markdown
Member

📌 개요

  • 식당 식단 조회 책임을 정리하고, 메뉴 그룹화 결과를 서비스에서 제공하도록 개선합니다.

✨ 작업 내용

  • 식단 조회 서비스가 확정된 날짜와 식사 시간을 기준으로 조회하도록 단순화했습니다.
  • Native API와 카카오 메시지 흐름에서 날짜/시간을 결정한 뒤 동일한 식단 조회 서비스를 호출하도록 변경했습니다.
  • 식단 메뉴 그룹화 규칙을 서비스 결과의 menuGroups로 통합해 응답 생성과 메시지 생성의 중복 로직을 제거했습니다.
  • 사용하지 않는 Warmup 모듈과 서비스, 스케줄 의존성을 제거했습니다.
  • 식단 조회 서비스 테스트를 변경된 책임과 그룹화 규칙 기준으로 갱신했습니다.

🔥 변경 이유

  • 기존에는 Native REST용 조회 메서드와 카카오 메시지용 조회 메서드가 날짜/시간 해석만 다를 뿐 식당 조회, 식단 조회, 결과 조립 로직을 중복으로 가지고 있었습니다.
  • 메뉴 그룹화 규칙도 컨트롤러와 메시지 팩토리에 각각 존재해 같은 도메인 규칙이 여러 곳에 퍼져 있었습니다.
  • 날짜/시간 결정은 호출 흐름의 입력 해석 책임으로 분리하고, 서비스는 확정된 조건으로 식단 도메인 결과를 조립하도록 역할을 명확히 했습니다.

🧪 테스트

  • 식단 조회 서비스가 Date, DietTime을 직접 받아 조회한다.
  • 식단 그룹화가 dishCategory 우선, 없으면 dishType, 둘 다 없으면 빈 문자열 기준으로 동작한다.
  • Native API와 카카오 메시지 팩토리에서 중복 그룹화 코드가 제거된다.
  • Warmup 관련 코드와 모듈 등록이 제거된다.
  • API 테스트와 lint check가 통과한다.

🔗 관련 이슈

Summary by CodeRabbit

Release Notes

  • Refactor

    • 카페테리아 식단 데이터 구조를 개선했습니다. 이제 메뉴가 카테고리별로 그룹화되어 더 명확하게 표시됩니다.
    • 식단 조회 엔드포인트에서 시간(아침/점심/저녁) 파라미터를 명시적으로 전달받도록 변경했습니다.
  • Chores

    • 내부 의존성을 정리하고 사용되지 않는 패키지를 제거했습니다.
    • 애플리케이션 초기화 프로세스를 간소화했습니다.

JangDongHo added 2 commits May 2, 2026 16:32
- WarmupModule 제거
- CafeteriaMessageFactory에서 diets를 menuGroups로 변경하여 카테고리별로 식단 정보를 그룹화
- CafeteriasService에서 getCafeteriaDiet 메서드 리팩토링, 식단 정보를 카테고리별로 반환하도록 수정
- 관련 DTO 및 테스트 코드 업데이트
@coderabbitai

coderabbitai Bot commented May 2, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Rate limit exceeded

@JangDongHo has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 4 minutes and 58 seconds before requesting another review.

To keep reviews running without waiting, you can enable usage-based add-on for your organization. This allows additional reviews beyond the hourly cap. Account admins can enable it under billing.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 263decd0-65e1-4cbf-92cc-bcbf0c544d73

📥 Commits

Reviewing files that changed from the base of the PR and between ae4281d and d75dd69.

📒 Files selected for processing (3)
  • mobile/services/cafeteriaApi.ts
  • services/api/app/src/api/public/cafeterias/cafeterias-native.controller.ts
  • services/api/app/src/api/public/cafeterias/dtos/requests/get-cafeteria-diet-query.dto.ts

Walkthrough

식당 식단 조회 책임을 재정의하고, 식단 그룹화 로직을 서비스 계층으로 통합하며, Warmup 모듈과 TypeORM 트랜잭션 래퍼를 제거합니다. 컨트롤러는 날짜/시간 결정을 담당하고, 서비스는 확정된 입력값으로 조회만 수행합니다.

Changes

식단 조회 책임 분리 및 그룹화 통합

Layer / File(s) Summary
DTO 데이터 구조
services/api/app/src/api/public/cafeterias/dtos/requests/list-cafeteria-diet-request.dto.ts, services/api/app/src/api/public/cafeterias/dtos/results/cafeteria-diet-result.dto.ts
DietTime 타입 추가, ListCafeteriaDietExtraRequestDto에 time 필드 추가. CafeteriaDietResult는 diets 대신 menuGroups: CafeteriaMenuGroupResult[] 반환 및 date, time 명시.
서비스 메서드 시그니처 & 그룹화 로직
services/api/app/src/api/public/cafeterias/cafeterias.service.ts
getCafeteriaDiet을 (cafeteriaId, date, time) 명시 인자로 단순화. getCafeteriaDietByDate 제거. groupDietsByCategory 헬퍼로 `dishCategory
컨트롤러 날짜/시간 결정
services/api/app/src/api/public/cafeterias/cafeterias.controller.ts, services/api/app/src/api/public/cafeterias/cafeterias-native.controller.ts
컨트롤러에서 getTodayOrTomorrow, getDietTime 호출하여 확정된 date, time 계산 후 서비스 호출. Native 컨트롤러의 로컬 Map 기반 그룹화 제거.
메시지 팩토리 단순화
services/api/app/src/api/public/cafeterias/cafeteria-message.factory.ts
menuGroups 직접 사용하여 메뉴 렌더링. 로컬 그룹화 로직 제거. 빈 메뉴 시 폴백 메시지 제거.
서비스 테스트 갱신
services/api/app/src/api/public/cafeterias/cafeterias.service.spec.ts
테스트를 문자열 기반 날짜에서 Date 객체로 변경. result.diets 대신 result.menuGroups 검증. 카테고리 우선순위 그룹화 테스트 추가. 기존의 자동 시간 결정 테스트 제거.

Warmup 모듈 제거 및 불필요한 의존성 정리

Layer / File(s) Summary
스케줄링 기능 제거
services/api/app/src/api/internal/warmup/warmup.service.ts, services/api/app/src/api/internal/warmup/warmup.module.ts
부트스트랩 및 5분 크론 스케줄 식단 프리워밍 로직 완전 제거. WarmupService, WarmupResult 인터페이스 삭제.
애플리케이션 모듈 정리
services/api/app/src/app.module.ts, services/api/app/src/main.ts
AppModule에서 WarmupModule, HttpModule 임포트 제거. OnApplicationBootstrap 라이프사이클 훅 및 HTTP 타임아웃 설정 제거. 비어있는 모듈로 단순화.
패키지 정리
services/api/app/package.json
@nestjs/schedule, @nestjs/axios, @sentry/*, @supabase/supabase-js, axios, dotenv, postgres, typeorm-transactional 제거. devDependencies에서 @snaplet/*, source-map-support, ts-loader 제거.

TypeORM 트랜잭션 래퍼 제거

Layer / File(s) Summary
트랜잭션 통합 제거
services/api/app/src/type-orm/database.module.ts, services/api/app/src/main.ts
DataSource, addTransactionalDataSource, getDataSourceByName 임포트 제거. dataSourceFactory 커스텀 로직 삭제. initializeTransactionalContext() 부트스트랩 호출 제거.
데코레이터 제거
services/api/app/src/api/public/users/users.service.ts
@Transactional() 데코레이터 제거. typeorm-transactional 임포트 제거. 메서드 본문 유지.
테스트 모킹 정리
services/api/app/src/api/public/users/users.service.spec.ts
typeorm-transactional Jest 모킹 블록 제거. 테스트 로직 변경 없음.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed PR 제목이 주요 변경 사항을 명확히 반영하고 있으며, 식단 조회 책임 정리 및 그룹화 구조 개선이라는 핵심 내용을 잘 전달합니다.
Description check ✅ Passed PR 설명이 제공된 템플릿 구조를 완벽하게 따르며, 개요, 작업 내용, 변경 이유, 테스트, 관련 이슈가 모두 상세하고 명확하게 기술되어 있습니다.
Linked Issues check ✅ Passed PR의 모든 변경 사항이 #78 이슈의 목표를 완전히 충족합니다. getCafeteriaDiet 시그니처 통합, 컨트롤러에서 날짜/시간 결정, menuGroups 그룹화 규칙 적용, Warmup 제거 등 모든 요구 사항이 구현되었습니다.
Out of Scope Changes check ✅ Passed 모든 변경 사항이 #78 이슈의 범위 내에 있으며, 식단 조회 책임 정리, 그룹화 통합, Warmup 제거 등 명시된 목표와 일치합니다. 범위를 벗어난 변경은 없습니다.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch refactor/#78

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


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
Review rate limit: 0/1 reviews remaining, refill in 4 minutes and 58 seconds.

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

@JangDongHo JangDongHo self-assigned this May 2, 2026
@JangDongHo JangDongHo added Refactor Cafeteria 구내식당 도메인 labels May 2, 2026
@JangDongHo
JangDongHo changed the base branch from main to dev May 2, 2026 07:40

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@services/api/app/src/api/public/cafeterias/cafeterias-native.controller.ts`:
- Around line 43-45: The default time selection uses getDietTime(date) which
uses the parsed query.date and can produce incorrect "current-time-based"
defaults; change the logic so when query.time is not provided you call
getDietTime(new Date()) (the actual current time) regardless of whether
query.date exists, e.g., keep date = query.date ? new Date(query.date) : new
Date() but compute time = query.time ?? getDietTime(new Date()) before calling
cafeteriasService.getCafeteriaDiet(cafeteriaId, date, time).
🪄 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

Run ID: f2e4d233-ca9f-43ae-b428-634b59d771db

📥 Commits

Reviewing files that changed from the base of the PR and between 4a1c84f and 5de2f21.

⛔ Files ignored due to path filters (1)
  • services/api/app/pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (11)
  • services/api/app/package.json
  • services/api/app/src/api/internal/warmup/warmup.module.ts
  • services/api/app/src/api/internal/warmup/warmup.service.ts
  • services/api/app/src/api/public/cafeterias/cafeteria-message.factory.ts
  • services/api/app/src/api/public/cafeterias/cafeterias-native.controller.ts
  • services/api/app/src/api/public/cafeterias/cafeterias.controller.ts
  • services/api/app/src/api/public/cafeterias/cafeterias.service.spec.ts
  • services/api/app/src/api/public/cafeterias/cafeterias.service.ts
  • services/api/app/src/api/public/cafeterias/dtos/requests/list-cafeteria-diet-request.dto.ts
  • services/api/app/src/api/public/cafeterias/dtos/results/cafeteria-diet-result.dto.ts
  • services/api/app/src/app.module.ts
💤 Files with no reviewable changes (4)
  • services/api/app/src/app.module.ts
  • services/api/app/src/api/internal/warmup/warmup.module.ts
  • services/api/app/package.json
  • services/api/app/src/api/internal/warmup/warmup.service.ts

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@services/api/app/src/app.module.ts`:
- Line 71: The bootstrap currently calls await app.listen(port) without
capturing the underlying HTTP server or setting timeouts; update main.ts to
capture the server instance returned by app.listen (e.g., const server = await
app.listen(port) or use app.getHttpServer()) and then explicitly set
server.keepAliveTimeout and server.headersTimeout to values compatible with your
nginx timeout (and ensure headersTimeout > keepAliveTimeout), so the Node.js
server timeouts align with reverse-proxy expectations.
🪄 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

Run ID: a91028f6-fdef-4dba-b85b-87a0d811aba0

📥 Commits

Reviewing files that changed from the base of the PR and between 5de2f21 and ae4281d.

⛔ Files ignored due to path filters (1)
  • services/api/app/pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (6)
  • services/api/app/package.json
  • services/api/app/src/api/public/users/users.service.spec.ts
  • services/api/app/src/api/public/users/users.service.ts
  • services/api/app/src/app.module.ts
  • services/api/app/src/main.ts
  • services/api/app/src/type-orm/database.module.ts
💤 Files with no reviewable changes (5)
  • services/api/app/src/main.ts
  • services/api/app/src/api/public/users/users.service.ts
  • services/api/app/src/api/public/users/users.service.spec.ts
  • services/api/app/src/type-orm/database.module.ts
  • services/api/app/package.json

Comment thread services/api/app/src/app.module.ts Resolved
- date 및 time 필드를 필수로 변경하여 유효성 검증 강화
- CafeteriasNativeController에서 getCafeteriaDiet 호출 시 time 파라미터 처리 방식 수정
@JangDongHo
JangDongHo merged commit b80518f into dev May 3, 2026
2 checks passed
@JangDongHo
JangDongHo deleted the refactor/#78 branch May 3, 2026 08:46
@JangDongHo JangDongHo changed the title 식단 조회 책임 및 그룹화 구조 개선 [Refactor] 식단 조회 책임 및 그룹화 구조 개선 Jun 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Cafeteria 구내식당 도메인 Refactor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

식단 조회 책임 및 그룹화 구조 개선 (getCafeteriaDiet)

1 participant