-
Notifications
You must be signed in to change notification settings - Fork 7
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
Populate and use started_at
column in trip
table for disambiguating trips
#125
Comments
Ah this is gnarly :) I think your solution would certainly work, though it may make the API somewhat confusing because it kind of breaks the REST semantics. I wonder as an alternative could we transform the trip ID for every realtime trip that comes into Transiter, and use that as the "trip ID" that we store in the database? We could then persist the regular trip ID as |
Good points! I think changing the trip id format is definitely nicer from a REST perspective, but my concern is that it loses the 1-to-1 mapping with the source GTFS content. A couple other solutions I was thinking about:
Curious to know your thoughts! Also I should mention this isn't, from my view, an urgent issue, just something I was thinking about while reading GTFS documentation. My intuition is it's relatively rare in the wild, but I've neither run into it nor gone out of my way to look for such cases as of yet. |
I believe we could maintain the 1-1 mapping. Suppose we had the following convention for the "normalized trip ID":
In this case given a normalized trip ID, you can split on the last two As you say in option (2), we could also have options where this other trip ID is an alias for the regular trip ID, and so the API would work with either option as long as there is no ambiguity. Our conversation so far has been very theoretical :) it would be interesting I think to find examples of systems that have this issue (maybe Amtrack?). Also it seems to be related to the GTFS |
The field
started_at
is currently not populated/used or used in thetrip
table. There are 2 reasons this can be useful:(1) is a longer term concern associated with the work described in #11, but (2) could prove useful for general data integrity with the existing API.
To accomplish this, the
transiter.public.trip.trip_route_pk_id_key
, will have to be changed to incorporate thestarted_at
field as well (e.g.,transiter.public.trip.trip_started_at_route_pk_id_key
). This will break the assumption used throughout the system that, at any given point, there is a unique trip ID per route. For example,/systems/{system_id}/routes/{route_id}/trips/{trip_id}
always returns a single trip. I believe this can be mostly solved with the below changes:Trip
orTrip.Reference
is returned by the API, also return thestarted_at
field..../trips/{trip_id}
endpoint, add an optional query parameter?started_at={date}
to disambiguate multiple trips with the same ID. If this query parameter is not provided, always return the earliest trip. I believe the default case matches what would happen today, since the later trip could not be added to the table until the earlier trip ends.@jamespfennell please let me know if agree with above problem statement and if you think this sounds like a workable solution.
The text was updated successfully, but these errors were encountered: