Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BREAKING CHANGE: change EventTime enum #7899

Open
wants to merge 5 commits into
base: dev
Choose a base branch
from

Conversation

dxrknesss
Copy link
Contributor

@dxrknesss dxrknesss commented Dec 9, 2024

GreenCity PR

Issue Link 📋

#6824

Changed

  • Renamed enum EventTime value from 'FUTURE' to 'UPCOMING' in order to comply with needed value.

Summary of Changes

This change should fix the bug from issue #6824, if merged at the same time with front-end fix.

Summary by CodeRabbit

  • New Features

    • Enhanced event filtering: The event filter checkbox and its label have been updated from “Future” to “Upcoming” for clearer categorization.
    • Added a method to generate a predefined list of event data, improving data handling capabilities.
  • Bug Fixes

    • Improved error handling and clarity in event time filtering logic.
  • Tests

    • Introduced a new test class for validating event search functionality, ensuring robustness in event retrieval processes.
  • Chores

    • Added a new dependency for the modelmapper library to facilitate testing.

@dxrknesss dxrknesss added this to the Java S52.2 milestone Dec 9, 2024
@dxrknesss dxrknesss self-assigned this Dec 9, 2024
@dxrknesss dxrknesss linked an issue Dec 9, 2024 that may be closed by this pull request
Copy link

sonarqubecloud bot commented Dec 9, 2024

Copy link
Contributor

@LazarenkoDmytro LazarenkoDmytro left a comment

Choose a reason for hiding this comment

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

No further comments are necessary following Roma’s remarks

Copy link

coderabbitai bot commented Feb 19, 2025

Warning

Rate limit exceeded

@dxrknesss has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 9 minutes and 10 seconds before requesting another review.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 997457c and 2672cb4.

📒 Files selected for processing (4)
  • dao/pom.xml (1 hunks)
  • dao/src/main/java/greencity/repository/impl/EventSearchRepoImpl.java (2 hunks)
  • dao/src/test/java/greencity/ModelUtils.java (2 hunks)
  • dao/src/test/java/greencity/repository/impl/EventSearchRepoImplTest.java (1 hunks)

Walkthrough

The pull request updates the event filtering terminology throughout the application. In the HTML template, a checkbox input and its label were modified from "Future" to "Upcoming." The repository implementation now uses a switch statement to handle event times, accommodating the new "UPCOMING" value, and the corresponding enum constant has been renamed from FUTURE to UPCOMING. Additionally, new integration tests and a PostgreSQL initializer have been added to support repository testing.

Changes

File(s) Change Summary
core/.../management_events.html Updated checkbox input and label from "future"/FUTURE to "upcoming"/UPCOMING for event filtering.
dao/.../EventSearchRepoImpl.java Modified the event time predicate logic from an if/else to a switch statement to handle EventTime.UPCOMING and EventTime.PAST.
dao/.../EventSearchRepoImplTest.java
dao/.../PostgresInitializer.java
Added new test class EventSearchRepoImplTest and an abstract class PostgresInitializer to facilitate PostgreSQL-based integration testing.
service-api/.../EventTime.java Renamed enum constant from FUTURE to UPCOMING to match updated event filtering terminology.
dao/pom.xml Added new dependency for modelmapper with test scope.
dao/.../ModelUtils.java Introduced new method getListEventDto() to create a list of EventDto objects.

Suggested reviewers

  • KizerovDmitriy
  • Warded120
  • RomaMocherniuk
  • VasylyshynDmytro

Poem

I'm a rabbit with a joyful hop,
In code gardens where changes never stop.
"Upcoming" replaced "Future" with flair,
In tests and logic, freshness is in the air.
Through switch and check, our code runs neat—
Hop along, in updates so sweet! 🐇💻


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ 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. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @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: 2

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 281188d and cb06088.

📒 Files selected for processing (5)
  • core/src/main/resources/templates/core/management_events.html (1 hunks)
  • dao/src/main/java/greencity/repository/impl/EventSearchRepoImpl.java (1 hunks)
  • dao/src/test/java/greencity/repository/impl/EventSearchRepoImplTest.java (1 hunks)
  • dao/src/test/java/greencity/repository/util/PostgresInitializer.java (1 hunks)
  • service-api/src/main/java/greencity/enums/EventTime.java (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • service-api/src/main/java/greencity/enums/EventTime.java
🧰 Additional context used
🪛 GitHub Actions: CI/CD GreenCity
dao/src/main/java/greencity/repository/impl/EventSearchRepoImpl.java

[error] 148-148: switch without "default" clause

🔇 Additional comments (2)
dao/src/test/java/greencity/repository/util/PostgresInitializer.java (1)

1-18: LGTM! Well-structured test database setup.

The implementation provides a robust and reusable test database setup using testcontainers. The class is correctly marked as abstract, and the properties are properly configured for both datasource and liquibase.

core/src/main/resources/templates/core/management_events.html (1)

176-178: LGTM! Consistent terminology update.

The checkbox label and value have been correctly updated from "Future" to "Upcoming", maintaining consistency with the backend changes.

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: 1

🧹 Nitpick comments (2)
dao/src/test/java/greencity/ModelUtils.java (2)

14-17: Remove unused imports.

The following imports are not used in the code:

  • java.sql.Date
  • java.time.temporal.ChronoUnit
  • java.time.temporal.TemporalAmount
-import java.sql.Date;
-import java.time.temporal.ChronoUnit;
-import java.time.temporal.TemporalAmount;

34-104: Reduce code duplication by extracting common builder patterns.

The method contains duplicated builder patterns for creating event DTOs. Consider extracting common patterns into helper methods.

+    private static EventDto.EventDtoBuilder baseEventDtoBuilder() {
+        return EventDto.builder()
+            .type(EventType.ONLINE)
+            .isOpen(true)
+            .isSubscribed(true)
+            .isFavorite(true)
+            .isRelevant(true)
+            .likes(0)
+            .countComments(2)
+            .isOrganizedByFriend(false)
+            .eventRate(3.5)
+            .description("123")
+            .titleImage("image.png");
+    }
+
+    private static AddressDto.AddressDtoBuilder baseAddressBuilder() {
+        return AddressDto.builder()
+            .latitude(0.0)
+            .longitude(1.0)
+            .cityEn("Kyiv");
+    }
+
     public static List<EventDto> getListEventDto() {
         return List.of(
-            EventDto.builder()
+            baseEventDtoBuilder()
                 .id(3L)
                 .title("test3")
                 .organizer(EventAuthorDto.builder().id(1L).name("Test3").build())
                 .creationDate(LocalDate.now().plus(Period.ofDays(12)))
                 // ... rest of the builder chain
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between cb06088 and feb68a3.

📒 Files selected for processing (4)
  • dao/pom.xml (1 hunks)
  • dao/src/main/java/greencity/repository/impl/EventSearchRepoImpl.java (3 hunks)
  • dao/src/test/java/greencity/ModelUtils.java (2 hunks)
  • dao/src/test/java/greencity/repository/impl/EventSearchRepoImplTest.java (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • dao/src/main/java/greencity/repository/impl/EventSearchRepoImpl.java
  • dao/src/test/java/greencity/repository/impl/EventSearchRepoImplTest.java
🔇 Additional comments (2)
dao/pom.xml (1)

108-114: Test Dependency for ModelMapper Added

The new dependency for org.modelmapper:modelmapper is correctly added with a test scope. Please ensure that the property ${modelmapper.version} is defined in your project (or parent POM) to avoid any dependency resolution issues at build time.

dao/src/test/java/greencity/ModelUtils.java (1)

34-104:

❓ Verification inconclusive

Add test data for the UPCOMING event time.

Given that this PR introduces a breaking change by renaming the 'FUTURE' enum value to 'UPCOMING', consider adding test data that explicitly covers this scenario.

Let's verify if the EventTime enum is used in the EventDto:


🏁 Script executed:

#!/bin/bash
# Description: Check if EventDto uses EventTime enum
ast-grep --pattern 'class EventDto {
  $$$
  EventTime $_ = $_
  $$$
}'

Length of output: 73


Test Data Update Required for UPCOMING Event Time

It appears that the test data in dao/src/test/java/greencity/ModelUtils.java only creates events with an ONLINE type. Since the PR renames the FUTURE enum value to UPCOMING, please add a test case that covers this new state. Note that our automated check using ast-grep did not reveal any usage of an EventTime field in EventDto, so please manually verify whether the renamed enum impacts additional parts of the codebase or if additional test data is required elsewhere.

  • Action Items:
    • Create a test case in the relevant test data (e.g., in ModelUtils.java) that uses the UPCOMING event time.
    • Manually review related tests to confirm that all scenarios relying on the renamed enum value are correctly updated.

@dxrknesss dxrknesss force-pushed the bug/6824/future-upcoming branch from feb68a3 to 997457c Compare February 24, 2025 10:53
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: 1

♻️ Duplicate comments (1)
dao/src/test/java/greencity/ModelUtils.java (1)

43-44: 🛠️ Refactor suggestion

Use fixed dates instead of relative ones to ensure test determinism.

The current implementation uses ZonedDateTime.now() with relative offsets, which could make tests non-deterministic.

Also applies to: 77-79

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between feb68a3 and 997457c.

📒 Files selected for processing (4)
  • dao/pom.xml (1 hunks)
  • dao/src/main/java/greencity/repository/impl/EventSearchRepoImpl.java (2 hunks)
  • dao/src/test/java/greencity/ModelUtils.java (2 hunks)
  • dao/src/test/java/greencity/repository/impl/EventSearchRepoImplTest.java (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • dao/pom.xml
  • dao/src/test/java/greencity/repository/impl/EventSearchRepoImplTest.java
  • dao/src/main/java/greencity/repository/impl/EventSearchRepoImpl.java
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: build
🔇 Additional comments (1)
dao/src/test/java/greencity/ModelUtils.java (1)

3-19: LGTM!

The imports are well-organized and all are utilized in the implementation.

@dxrknesss dxrknesss force-pushed the bug/6824/future-upcoming branch from 997457c to 2672cb4 Compare February 24, 2025 11:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Events/Event filters]The "Upcoming" filter is called 'Future'
4 participants