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 1 commit into
base: dev
Choose a base branch
from

Conversation

dxrknesss
Copy link

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.

@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

@@ -1,6 +1,6 @@
package greencity.enums;

public enum EventTime {
FUTURE,

Choose a reason for hiding this comment

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

I see that we use FUTURE here
Do you think we should update it as well?

@@ -145,7 +145,7 @@ private Predicate getPredicate(FilterEventDto filterEventDto, Long userId, Root<
private void addEventTimePredicate(EventTime eventTime, Root<Event> eventRoot, List<Predicate> predicates) {
if (eventTime != null) {
ListJoin<Event, EventDateLocation> datesJoin = eventRoot.join(Event_.dates, JoinType.LEFT);
if (eventTime == EventTime.FUTURE) {
if (eventTime == EventTime.UPCOMING) {

Choose a reason for hiding this comment

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

Please add test for this case

Copy link
Author

Choose a reason for hiding this comment

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

how do you want me to test it? with unit or integration test? I don't quite get how to unit test it, there's so many thing I need to mock. integration test will be way easier to write in this case, don't you agree?

@@ -145,7 +145,7 @@ private Predicate getPredicate(FilterEventDto filterEventDto, Long userId, Root<
private void addEventTimePredicate(EventTime eventTime, Root<Event> eventRoot, List<Predicate> predicates) {
if (eventTime != null) {
ListJoin<Event, EventDateLocation> datesJoin = eventRoot.join(Event_.dates, JoinType.LEFT);
if (eventTime == EventTime.FUTURE) {
if (eventTime == EventTime.UPCOMING) {
predicates.add(
criteriaBuilder.greaterThan(datesJoin.get(EventDateLocation_.FINISH_DATE), ZonedDateTime.now()));
} else if (eventTime == EventTime.PAST) {

Choose a reason for hiding this comment

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

Why do we need else if here?
There are only 2 items in the EventTime enum
I think it is better to have 2 separate if here

Copy link

@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

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'
3 participants