Skip to content

refactor: 마지막 수정 시간 조회 api 추가#67

Merged
GoToBILL merged 1 commit intodevelopfrom
feature/mixed
Oct 21, 2025
Merged

refactor: 마지막 수정 시간 조회 api 추가#67
GoToBILL merged 1 commit intodevelopfrom
feature/mixed

Conversation

@GoToBILL
Copy link
Contributor

@GoToBILL GoToBILL commented Oct 21, 2025

Summary by CodeRabbit

  • New Features

    • Added a new GET /last-modified API endpoint that returns the timestamp of when guides were last modified.
  • Chores

    • Optimized database query performance by adding indexes to frequently accessed columns.

@coderabbitai
Copy link

coderabbitai bot commented Oct 21, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

A new "last modified" feature enables retrieving the latest modification timestamp across all guides through a new REST API endpoint. Supporting changes include database indexing on updatedAt and sub_category_id columns, a new repository query method, and a DTO for the response. BaseTimeEntity's deletion behavior is updated to also reflect deletion time in the updatedAt timestamp.

Changes

Cohort / File(s) Summary
Entity & Database Layer
src/main/java/com/example/chalpu/common/entity/BaseTimeEntity.java, src/main/java/com/example/chalpu/guide/domain/Guide.java
Modified BaseTimeEntity's setDeletedAt() to also update updatedAt timestamp. Added database indexes to Guide: idx_guide_updated_at on updatedAt column and idx_guide_sub_category_is_active on sub_category_id, isActive columns.
Repository Layer
src/main/java/com/example/chalpu/guide/repository/GuideRepository.java
Added new query method findMaxUpdatedAt() that retrieves the maximum updatedAt timestamp across all Guide entities.
Service Layer
src/main/java/com/example/chalpu/guide/service/GuideService.java
Introduced new method getLastModifiedTime() that queries repository for max updatedAt, logs the result, and returns wrapped in GuideLastModifiedResponse DTO.
Data Transfer Object
src/main/java/com/example/chalpu/guide/dto/GuideLastModifiedResponse.java
New record with single field lastModifiedAt (String). Includes static factory method from(LocalDateTime) for conversion.
API Endpoint
src/main/java/com/example/chalpu/guide/controller/GuideController.java
Added new GET /last-modified endpoint that invokes guideService.getLastModifiedTime() and wraps response in ApiResponse.

Sequence Diagram

sequenceDiagram
    participant Client
    participant GuideController
    participant GuideService
    participant GuideRepository
    participant Database
    
    Client->>GuideController: GET /last-modified
    GuideController->>GuideService: getLastModifiedTime()
    GuideService->>GuideRepository: findMaxUpdatedAt()
    GuideRepository->>Database: SELECT MAX(g.updatedAt) FROM Guide g
    Database-->>GuideRepository: LocalDateTime
    GuideRepository-->>GuideService: LocalDateTime
    Note over GuideService: Log timestamp
    GuideService->>GuideService: Build GuideLastModifiedResponse
    GuideService-->>GuideController: GuideLastModifiedResponse
    GuideController->>GuideController: Wrap in ApiResponse
    GuideController-->>Client: ApiResponse<GuideLastModifiedResponse>
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

The changes follow a consistent, predictable pattern across the layered architecture (entity → repository → service → DTO → controller). While spanning multiple files, the modifications are homogeneous in nature—each file implements a clear, single responsibility in the feature flow. The addition of database indexes and the deletion timestamp propagation require focused review but are straightforward conceptually.

Poem

🐇 A guide through time, now swiftly found,
Last modified brings updates sound,
With indexes swift and timestamps true,
Deletion marks what once shone new.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feature/mixed

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e0cf8b0 and 7934386.

📒 Files selected for processing (6)
  • src/main/java/com/example/chalpu/common/entity/BaseTimeEntity.java (1 hunks)
  • src/main/java/com/example/chalpu/guide/controller/GuideController.java (2 hunks)
  • src/main/java/com/example/chalpu/guide/domain/Guide.java (1 hunks)
  • src/main/java/com/example/chalpu/guide/dto/GuideLastModifiedResponse.java (1 hunks)
  • src/main/java/com/example/chalpu/guide/repository/GuideRepository.java (2 hunks)
  • src/main/java/com/example/chalpu/guide/service/GuideService.java (4 hunks)

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 and usage tips.

@GoToBILL GoToBILL merged commit ceb6dc4 into develop Oct 21, 2025
1 check was pending
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