Repository navigation
Refactoring SIRI StopConditions from TransitAlert to EntitySelector - #4196
Conversation
|
What about setting up separate indices for each |
9fabcd4 to
72801c7
Compare
|
This is now ready for review. However we need to discuss the semantics of the handling around the service date for a Trip keyed alert. Should we return alerts which don't have any date associated to a trip when requesting the alerts for a trip for a specific date? |
|
I think alerts tagged on a Trip by ID (and not a specific date) should apply to all occurrences of that trip within the defined validity-period for the alert. I.e. no specified date then means "any date". |
ecc5ebf to
2bb2a35
Compare
| public class StopConditionsHelper { | ||
|
|
||
| /** | ||
| * Matches an EntitySelector's stopConditions with the stopConditions required. Returns true |
There was a problem hiding this comment.
I don't understand this sentence.
| Set<StopCondition> stopConditions = isFirstLeg | ||
| ? StopCondition.DEPARTURE | ||
| : StopCondition.FIRST_DEPARTURE; |
There was a problem hiding this comment.
Isn't this logic upside down? I would expect first leg to use StopCondition.FIRST_DEPARTURE.
|
|
||
| @Override | ||
| public Collection<TransitAlert> getStopAlerts(FeedScopedId stop) { | ||
| public Collection<TransitAlert> getStopAlerts( |
There was a problem hiding this comment.
Can you add some javadoc on the class here (not needed for the methods) so it's easier to understand what is the purpose of this Delegating service.
| // Then transitAlertService should have been called with stop and route ids | ||
| Mockito.verify(transitAlertService, Mockito.atLeastOnce()).getStopAlerts(A.stop.getId()); | ||
| Mockito.verify(transitAlertService, Mockito.atLeastOnce()).getStopAlerts(E.stop.getId()); | ||
| Mockito |
There was a problem hiding this comment.
Just out of curiosity, do we need to use mockito here?
There was a problem hiding this comment.
We check that the transitAlertService gets queried with the correct arguments, without needing to have one.
Codecov ReportBase: 60.46% // Head: 60.48% // Increases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## dev-2.x #4196 +/- ##
=============================================
+ Coverage 60.46% 60.48% +0.01%
- Complexity 12110 12125 +15
=============================================
Files 1574 1577 +3
Lines 63274 63232 -42
Branches 7005 6992 -13
=============================================
- Hits 38256 38243 -13
+ Misses 22838 22807 -31
- Partials 2180 2182 +2
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
Summary
The SIRI SX StopConditions can be defined separately on each StopPoint, and OTP needs to support that. Today the StopConditions are combined and added to the entire TransitAlert.
This PR is intended to be the starting point of a discussion on how this best should be solved.
Necessary requirements:
Example-datastructure:
Each stop may have a different set of StopConditions that needs to be included in each EntitySelector
When adding alerts to a trip-result in
AlertToLegMapper, the EntitySelector should only return a match if both the stopId match, and at least one of the EntitySelector's StopConditions matches the current StopCondition-filter for each part of theLeg.E.g. if a leg matches both trip and stops in the example above:
-filtering on
START_POINTshould return EntitySelector 1 and 2-filtering on
DESTINATIONshould return EntitySelector 2 and 3-filtering on both
START_POINTandDESTINATIONshould return all 3-filtering on
REQUEST_STOPshould return none of them-when the filter is empty, all EntitySelectors should be returned
Currently, the EntitySelector for e.g. trip/stop is matched by using an equals/hashcode towards a HashMap in the index. When matching StopConditions in an EntitySelector, the StopConditions used to filter does not necessarily need to be equal, but can either contain a subset or superset of the StopConditions in the EntitySelector - or the filter can be empty. Because of this, it is not obvious that the StopCondition-matching should be performed in the
equals().Any good ideas?
Issue
closes #4142