Adjust search window dynamically to fit the number of itineraries - #3828
Conversation
Extract duplicate code and generate the previous and next token together.
Extract duplicate code and generate the previous and next token together.
The filter chain is responsible for sorting and cropping the itinerary list is the maxNumOfItineraries is reached. Before this commit these features were tied to the request#arriveBy. By removing this coupling we can later use the sort-order and cropping independently of what the arriveBy is, witch is needed for pageing to work properly.
We will add doc and several new classes to this package later.
Refactor the PageCursorFactoryTest by removing boilerplate and update test names to match design doc.
This will make code easier to read and later changes easier to diff and compare with the design doc.
The 'transitTimeZero' is the base for all scheduled times for this request/search. It is usually at midnight for the given request 'dateTime' and all schedule times are relative to this point in time.
We need to include an extra minute when using the last minute to be included in the seach window to calculate the start of it.
If the result have too few or too many itineraries we adjust the search-window for the next request to better fit the expected size of the search-window.
Co-authored-by: Hannes Junnila <hannes.junnila@gmail.com>
I have addressed most of this in comments/fixes above, but I will try to give a summary here:
|
| * arriveBy is true) | ||
| */ | ||
| private long dateTime = new Date().getTime() / 1000; | ||
| private Instant dateTime = Instant.now(); |
There was a problem hiding this comment.
Yes, the Instant is a wrapper around epocSeconds, and getting rid of all the slightly different accessors for dataTime felt good. I see now that I forgot to update that JavaDoc, but I think I will draw the line here - there are 95% technical improvements in this PR...
Co-authored-by: Leonard Ehrenfried <mail@leonard.io>
…w_in_sub_seq_searches
196b80a
|
I added the possibility to configure the This files are changed:
|
|
This looks really good. Do you want to add a line to Configuration.md about |
|
I can do it as a separate PR maybe to get this merged, I do not remember if we document the request parameters. |
Summary
If the result have too few or too many itineraries we adjust the search-window for the next request to better fit the expected size of the search-window. This is not done for the initial search, but for all searches after that. The search-window will scale down to fit the numOfItineraries asked for, or up to 6 itineraries in the result. When paging from a high frequency
In addition this PR also clean up the Paging functionality and add documentation for this.
fix: Calculate start of search window correct
We need to include an extra minute when we want to include the "first removed itinerary" start time in the search window. The search window is [inclusive, exclusive] so to include a time t at the end the search window need to be [t0 , t+1m].
Issue
There is no issue for this.
Unit tests
New unit tests are added and old updated.
Code style
✅
Documentation
✅ This add design doc for paging
Changelog
✅