Skip to content

Job for validating trips in active alerts against /services endpoint - #1476

Open
allisonking wants to merge 16 commits into
mainfrom
aking/trip-checker
Open

allisonking wants to merge 16 commits into
mainfrom
aking/trip-checker

Conversation

@allisonking

@allisonking allisonking commented Nov 23, 2026 •

Copy link
Copy Markdown
Collaborator

✔️ Update our GTFS validation for obsolete entities for trips

Description

Adds a new job TripValidationWorker which runs once a day at 4am EST. This job does the following:

  1. Get a list of all open alerts that have trips in them
  2. For each of those trips, check their service_id
  3. From those service_ids, query the /services endpoint and compare today's date to the last day of the service
    1. The last day of the service is probably the end_date, but we also check added_dates and removed_dates to make sure
    2. i.e. if we have an end_date of 12/2, but an added_dates=[12/15] , then 12/15 is the last valid date. Or if for some reason we have removed_dates=[12/2] , then 12/1 becomes the last valid date
  4. If today's date is less than threshold from the last day of the service, we log out a message so we can use splunk to send an email to Keolis. I currently have threshold set to 1 day, but we can change that
    1. The benefit of threshold being higher than 1 day is Keolis would have more time to update the alert. The con is that we risk sending a false positive if the alert was going to close anyway
      1. We could add a thing to check for the end time of an alert to mitigate false positives, but this would only work for alerts with known durations
  5. I checked with transit data, and they said the obsolete trips drop out of GTFS 7 days after the last relevant service ran, so with a threshold of 1, I believe that gives Keolis 8 days before gtfs creator breaks (but only 1 day before the alert has obsolete data)

The splunk alert is currently set up on dev-orange

Acceptance Criteria

  1. Query the /services endpoint using each service id (example API query) and check when the end_date is
    • If the end_date is going to be the next day, we should send an email
      • To our internal group (just direct alerts team; Nate/Claire), and to Keolis
    • At EOS on the end_date , alerts can transform everything over to the new trip ID ⬅️ we decided to start with just an email first
  2. Would need to reconcile with existing worker task we run ⬅️ still need to do this, will make it a separate ticket. Now that I understand the flow better, I think it makes sense to only run this once a day
    • Runs every time API is updated
    • Probably check this every time we run that? (Probably every 5 mins)

Uses an updated `mbta_v3_api` so we can query for all services by a list of IDs instead of querying for each service one by one
@allisonking
allisonking marked this pull request as ready for review November 25, 2026 19:41

This branch was successfully deployed

1 active (outdated) deployment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant