Skip to content

feat: 약 복용 알림 기능 추가#176

Merged
Neibce merged 1 commit intomainfrom
be/feat/pill-reminder
Aug 21, 2025
Merged

feat: 약 복용 알림 기능 추가#176
Neibce merged 1 commit intomainfrom
be/feat/pill-reminder

Conversation

@Neibce
Copy link
Owner

@Neibce Neibce commented Aug 21, 2025

Summary by CodeRabbit

  • 신기능
    • 복약 시간에 맞춰 자동 푸시 알림을 발송합니다. 요일/시간과 오늘의 복용 여부를 확인해 필요한 경우에만 전송하며, iOS/Android 모두 지원합니다. 알림에는 약 이름과 안내 문구가 포함되어 복용을 놓치지 않도록 도와줍니다.
    • 약을 삭제하면 해당 약의 모든 복용 기록도 함께 삭제되어 기록 관리가 더 간편해졌습니다.

@coderabbitai
Copy link

coderabbitai bot commented Aug 21, 2025

Walkthrough

PillIntakeRecordRepository에 intakeDate 기반 조회와 Pill 기준 삭제 메서드가 추가되었고, PillService에 FCM 기반 복약 알림 스케줄러와 알림 전송 로직이 도입되었습니다. 또한 Pill 삭제 시 관련 PillIntakeRecord 일괄 삭제가 연계되었습니다.

Changes

Cohort / File(s) Summary of Changes
Repository: intake 조회/삭제 확장
backend/ongi/src/main/java/ongi/pill/repository/PillIntakeRecordRepository.java
메서드 추가: findByIntakeDate(LocalDate), deleteByPill(Pill). 기존 메서드 유지.
Service: 알림 스케줄러·FCM 연동 및 삭제 연계
backend/ongi/src/main/java/ongi/pill/service/PillService.java
스케줄러 checkAndSendMedicationAlarms() 추가. 요일/시간/기록 여부 기반의 복약 알림 대상 판별, 사용자 FCM 토큰 조회 후 FirebaseMessaging으로 Android/iOS 구성 포함 알림 전송. Pill 삭제 시 관련 복용기록 삭제 로직 연계. 부수적 포맷 정리 및 import 추가.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor Scheduler
  participant PillService
  participant PillRepository as PillRepo
  participant IntakeRepo as PillIntakeRecordRepo
  participant TokenRepo as UserFcmTokenRepo
  participant FCM as FirebaseMessaging

  Scheduler->>PillService: checkAndSendMedicationAlarms()
  activate PillService
  PillService->>PillRepo: 조회: 활성/사용자별 Pill
  PillService->>IntakeRepo: 오늘자 복용기록 조회(필요 시)
  PillService->>PillService: 요일/시간 기준 미복용 Pill 필터링
  loop 각 대상 Pill
    PillService->>TokenRepo: 소유자 FCM 토큰 조회
    alt 토큰 존재
      PillService->>FCM: Message 전송(Android/iOS 설정 포함)
      FCM-->>PillService: 전송 결과/에러
      note over PillService,FCM: 개별 실패는 캐치하고 다음 Pill 진행
    else 토큰 없음
      Note over PillService: 전송 스킵
    end
  end
  deactivate PillService
Loading
sequenceDiagram
  autonumber
  actor Client
  participant PillService
  participant IntakeRepo as PillIntakeRecordRepo
  participant PillRepo

  Client->>PillService: deletePill(pillId)
  activate PillService
  PillService->>IntakeRepo: deleteByPill(Pill)
  IntakeRepo-->>PillService: 삭제 완료
  PillService->>PillRepo: delete(Pill)
  PillRepo-->>PillService: 삭제 완료
  deactivate PillService
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Poem

작은 귀 파닥, 분 단위로 똑딱-딱! ⏰
알약 이름 불러주며 푸시 하나 퐁!
안 먹은 기록 찾고, 먹을 시간 콩콩.
지울 땐 흔적 없이 슉—기록도 함께 쓱.
오늘의 캐럿은 안정된 알림 흐름🥕


📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Free

💡 Knowledge Base configuration:

  • Jira integration is disabled
  • Linear integration is disabled

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 8ddd03f and 7a2669e.

📒 Files selected for processing (2)
  • backend/ongi/src/main/java/ongi/pill/repository/PillIntakeRecordRepository.java (1 hunks)
  • backend/ongi/src/main/java/ongi/pill/service/PillService.java (7 hunks)

Note

🎁 Summarized by CodeRabbit Free

Your organization is on the Free plan. CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please upgrade your subscription to CodeRabbit Pro by visiting https://app.coderabbit.ai/login.

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Join our Discord community for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@Neibce Neibce merged commit ae35ff7 into main Aug 21, 2025
4 checks passed
@Neibce Neibce deleted the be/feat/pill-reminder branch August 21, 2025 20:24
Neibce added a commit that referenced this pull request Aug 21, 2025
Neibce added a commit to 2025-PNU-SW-Hackathon/PNUSW-2025-OnGi-10 that referenced this pull request Aug 25, 2025
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.

1 participant