-
Notifications
You must be signed in to change notification settings - Fork 2
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
fix(check-monitored-trip): advance to next trip day when itinerary is no longer valid #284
Open
josh-willis-arcadis
wants to merge
1
commit into
dev
Choose a base branch
from
feature/OTP-1522-update-next-trip-day
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+29
−9
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,14 +29,7 @@ | |
import java.time.ZoneId; | ||
import java.time.ZonedDateTime; | ||
import java.time.temporal.ChronoUnit; | ||
import java.util.ArrayList; | ||
import java.util.Collections; | ||
import java.util.Date; | ||
import java.util.HashMap; | ||
import java.util.HashSet; | ||
import java.util.Locale; | ||
import java.util.Map; | ||
import java.util.Set; | ||
import java.util.*; | ||
import java.util.concurrent.TimeUnit; | ||
import java.util.function.Supplier; | ||
|
||
|
@@ -673,7 +666,7 @@ public boolean shouldSkipMonitoredTripCheck(boolean persist) throws Exception { | |
} | ||
} | ||
|
||
if (isPrevMatchingItineraryNotConcluded()) { | ||
if (isPrevMatchingItineraryNotConcluded() && isPrevMatchingItineraryDayValid()) { | ||
// Skip checking the trip the rest of the time that it is active if the trip was deemed not possible for the | ||
// next possible time during a previous query to find candidate itinerary matches. | ||
if (previousJourneyState.tripStatus == TripStatus.NEXT_TRIP_NOT_POSSIBLE) { | ||
|
@@ -771,6 +764,33 @@ public boolean shouldSkipMonitoredTripCheck(boolean persist) throws Exception { | |
return true; | ||
} | ||
|
||
// Check if previous matching itinerary day is still valid | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please change this to a method comment. Start with |
||
private boolean isPrevMatchingItineraryDayValid() { | ||
Calendar calendar = Calendar.getInstance(); | ||
calendar.setTime(previousMatchingItinerary.startTime); | ||
|
||
int dayOfWeek = calendar.get(Calendar.DAY_OF_WEEK); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit. You could in-line this variable. |
||
|
||
switch (dayOfWeek) { | ||
case Calendar.SUNDAY: | ||
return trip.sunday; | ||
case Calendar.MONDAY: | ||
return trip.monday; | ||
case Calendar.TUESDAY: | ||
return trip.tuesday; | ||
case Calendar.WEDNESDAY: | ||
return trip.wednesday; | ||
case Calendar.THURSDAY: | ||
return trip.thursday; | ||
case Calendar.FRIDAY: | ||
return trip.friday; | ||
case Calendar.SATURDAY: | ||
return trip.saturday; | ||
default: | ||
return false; // This should never happen, but for safety | ||
} | ||
} | ||
|
||
private void advanceToNextMonitoredDay() { | ||
// Check if the journeyState indicates that an itinerary has already been calculated in a previous run of | ||
// this CheckMonitoredTrip. If the targetDate is null, then the current date has not yet been checked. If | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We use explict imports. Can you revert this please. There is also a setting in Intellij (assuming you are using this) that prevents this.