Skip to content

Conversation

@kwon204
Copy link
Contributor

@kwon204 kwon204 commented Apr 14, 2025

#️⃣ 연관된 이슈>

📝 작업 내용> 이번 PR에서 작업한 내용을 간략히 설명해주세요(이미지 첨부 가능)

  • 사용자가 연동한 캘린더 정보(캘린더 이름)를 조회하는 기능 구현하였습니다.
  • 연동한 캘린더가 없다면 빈 리스트가 반환됩니다.

🙏 여기는 꼭 봐주세요! > 리뷰어가 특별히 봐주었으면 하는 부분이 있다면 작성해주세요

Summary by CodeRabbit

  • New Features
    • Introduced a new capability that lets users quickly view a consolidated list of their calendar entries.
    • Enhanced the retrieval of calendar data to ensure that your calendar information is displayed accurately and responsively.

@kwon204 kwon204 added the 🛠️ BE Backend label Apr 14, 2025
@kwon204 kwon204 added this to the 🦖10차 스프린트 milestone Apr 14, 2025
@kwon204 kwon204 self-assigned this Apr 14, 2025
@kwon204 kwon204 requested a review from efdao as a code owner April 14, 2025 14:40
@coderabbitai
Copy link

coderabbitai bot commented Apr 14, 2025

Walkthrough

A new endpoint has been introduced in the Calendar module. The CalendarController now exposes a /calendar/list GET endpoint that returns a list of calendar responses. The update adds a new method in the CalendarService to retrieve the current user's calendars via the repository method findAllByUserId. Additionally, a new DTO record CalendarResponse has been created to encapsulate calendar data. These changes extend data retrieval functionality without affecting existing endpoints.

Changes

File(s) Changed Summary
backend/src/.../calendar/CalendarController.java Added a new endpoint calendarList mapped to GET /calendar/list that returns a ResponseEntity with a ListResponse of CalendarResponse objects. Required imports (CalendarResponse, ListResponse, ResponseEntity) were also added.
backend/src/.../calendar/CalendarRepository.java Added a new method signature findAllByUserId(Long userId) to query and return a list of calendar entries associated with a given user ID.
backend/src/.../calendar/CalendarService.java Introduced the new public method getCalendarList() which retrieves the current user, queries the repository for their calendars, transforms the data to CalendarResponse objects, and packages them into a ListResponse. Also adjusted the formatting of an existing method.
backend/src/.../calendar/dto/CalendarResponse.java Created a new DTO record CalendarResponse with a single field name to encapsulate the calendar data for responses.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant Controller
    participant Service
    participant Repository

    Client->>Controller: GET /calendar/list
    Controller->>Service: getCalendarList()
    Service->>Repository: findAllByUserId(currentUser.id)
    Repository-->>Service: List<Calendar>
    Service->>Controller: ListResponse<CalendarResponse>
    Controller-->>Client: ResponseEntity.ok(ListResponse)
Loading

Possibly related PRs

Suggested labels

🖥️ FE

Suggested reviewers

  • efdao

Poem

I'm a tiny bunny with a hop in my step,
Delighting in new endpoints with each little pep.
I munch on code and nibble all day,
Celebrating changes in a playful way.
Happy to see the calendar bloom anew—cheers to the updates, woo-hoo!
🐰✨

Tip

⚡💬 Agentic Chat (Pro Plan, General Availability)
  • We're introducing multi-step agentic chat in review comments and issue comments, within and outside of PR's. This feature enhances review and issue discussions with the CodeRabbit agentic chat by enabling advanced interactions, including the ability to create pull requests directly from comments and add commits to existing pull requests.
✨ Finishing Touches
  • 📝 Generate Docstrings

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
🪧 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.
    • Generate unit testing code for this file.
    • 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. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • 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 src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

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

Documentation and Community

  • 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.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (3)
backend/src/main/java/endolphin/backend/domain/calendar/dto/CalendarResponse.java (1)

3-7: The CalendarResponse record appears to be oversimplified.

The current implementation only includes a name field, but calendars typically contain more information that users might find useful such as ID, description, color, or timezone. Consider expanding this record to include more relevant calendar properties to provide a richer response to clients.

public record CalendarResponse(
-    String name
+    String name,
+    Long id,
+    String description
) {

}
backend/src/main/java/endolphin/backend/domain/calendar/CalendarController.java (1)

50-54: Consider adding API documentation and following RESTful conventions.

While the endpoint implementation looks good, it would benefit from:

  1. Adding Swagger annotations for API documentation (@operation, @apiresponse)
  2. Using a more RESTful URL pattern (e.g., /calendars instead of /calendar/list)
  3. Adding security annotations if necessary to specify access permissions
+@Operation(summary = "Get all calendars for the current user", 
+          description = "Returns a list of calendars associated with the authenticated user")
+@ApiResponses(value = {
+    @ApiResponse(responseCode = "200", description = "Successfully retrieved calendars"),
+    @ApiResponse(responseCode = "401", description = "Unauthorized, authentication required")
+})
-@GetMapping("/calendar/list")
+@GetMapping("/calendars")
public ResponseEntity<ListResponse<CalendarResponse>> calendarList() {
    ListResponse<CalendarResponse> response = calendarService.getCalendarList();
    return ResponseEntity.ok(response);
}
backend/src/main/java/endolphin/backend/domain/calendar/CalendarService.java (1)

131-133: Consider including more properties in the calendar response.

The current implementation only maps the calendar name to the response. If Calendar entities contain more useful information like ID, description, or other metadata, consider including those in the response to provide a more comprehensive view for the client.

List<CalendarResponse> response = calendars.stream()
-    .map(c -> new CalendarResponse(c.getName())).toList();
+    .map(c -> new CalendarResponse(c.getName(), c.getId(), c.getDescription())).toList();
return new ListResponse<>(response);
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 094822f and fe85b04.

📒 Files selected for processing (4)
  • backend/src/main/java/endolphin/backend/domain/calendar/CalendarController.java (2 hunks)
  • backend/src/main/java/endolphin/backend/domain/calendar/CalendarRepository.java (1 hunks)
  • backend/src/main/java/endolphin/backend/domain/calendar/CalendarService.java (4 hunks)
  • backend/src/main/java/endolphin/backend/domain/calendar/dto/CalendarResponse.java (1 hunks)
🔇 Additional comments (2)
backend/src/main/java/endolphin/backend/domain/calendar/CalendarRepository.java (1)

24-25: LGTM! Method signature follows Spring Data JPA convention.

The new repository method properly follows Spring Data JPA naming conventions and complements the existing methods for calendar retrieval.

backend/src/main/java/endolphin/backend/domain/calendar/CalendarService.java (1)

126-134:

Details

❓ Verification inconclusive

Verify ListResponse constructor compatibility and error handling.

The current implementation looks good but has a couple of potential issues:

  1. From the provided code snippets, ListResponse constructor appears to require both a list and a totalCount parameter, but only the list is provided here.
  2. There's no explicit error handling for the case when no calendars are found.

🏁 Script executed:

#!/bin/bash
# Check ListResponse class definition to verify constructor parameters
echo "Checking ListResponse class definition..."
fd --type file --exec grep -l "ListResponse" {} \; | xargs grep -n "class ListResponse" -A 20

Length of output: 189


I'm not seeing the expected output regarding the definition of the ListResponse class. To clarify the concerns about the constructor signature and error handling, let's run an additional shell script to search for the ListResponse class definition and its constructor details across the repository.

Please execute this script so we can verify the constructor's parameters and then update the review comment accordingly.


🏁 Script executed:

#!/bin/bash
# Search recursively for the ListResponse class definition
rg -n "class ListResponse" .

# Search for constructor definitions in the ListResponse class
rg -n "public ListResponse(" .

Length of output: 154


Action: Manually Verify ListResponse Constructor and Handle Empty Results

The implementation appears acceptable overall, but please confirm two points manually:

  • Constructor Compatibility: It’s unclear whether the ListResponse class’s constructor requires both a list and a total count. The code currently passes only the list. Please verify that a single-argument constructor exists or, if not, update the code to pass the totalCount as well.
  • Error Handling for No Calendars: Although returning an empty list can be acceptable, consider whether the absence of explicit error handling when no calendars are found aligns with the intended business logic.

Copy link
Collaborator

@efdao efdao left a comment

Choose a reason for hiding this comment

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

고생하셨습니다. PR 작업내용 더 자세히 적어주세요

@kwon204 kwon204 merged commit 0f98b65 into dev May 12, 2025
7 checks passed
@kwon204 kwon204 deleted the feature/be/calendar-list branch May 12, 2025 01:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🛠️ BE Backend

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants