Handle informed trip descriptors with empty trip ids and non-empty route #18
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.
Overview
This change handles an edge case where the
trip
entity selector is used for providing alerts for a given route without atripId
.For example, the MTA buses provide alerts in this form sometimes:
In the above case, the alert effectively applies to the whole route since both directions are covered.
Note also that a tripID is not always required to uniquely identify a trip. A trip can sometimes be identified with a combination of
route_id
,direction_id
,start_time
, andstart_date
(see GTFS spec). If the tripID is empty but all of these fields are provided, we can consider the trip as potentially identifiable.We therefore consider the following cases for how to handle this:
1.) An alert has informed trips with no identifiable trip instance, a
routeId
, and both directions are specified (one in each entity, as in the above example): consider this alert as affecting the entire route and add a route informed entity.2.) An alert has an informed trip with no identifiable trip instance, a
routeId
, and no directions are specified: consider this alert as affecting the entire route and add a route informed entity.3.) An alert has an informed trip with no identifiable trip instance, a
routeId
and a single direction is specified: consider this alert as affecting the route running in that direction and inform the route/direction combination.In all 3 cases, the alert will not be associated with any trips, since a trip descriptor is required to uniquely identify a trip instance.
This change also discards informed entities for an alert that are considered of no use (i.e. they don't match any entities).