Skip to content
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

feat(api): Add API for getting active replacement services #1116

Open
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

rudiejd
Copy link
Contributor

@rudiejd rudiejd commented Feb 7, 2025

Summary of changes

Asana Ticket: 🏹 Implement /replacement_service API endpoint

Problem:
gtfs_creator needs to be able to know what alternative service options are available for all active disruptions so that it can create new trips and other GTFS entities

Solution:
Add replacement_service API that gtfs_creator can read to get all service that provided as a result of disruptions

Reviewer Checklist

  • Meets ticket's acceptance criteria
  • Any new or changed functions have typespecs
  • Tests were added for any new functionality (don't just rely on Codecov)
  • This branch was deployed to the staging environment and is currently running with no unexpected increase in warnings, and no errors or crashes.

@rudiejd rudiejd marked this pull request as draft February 7, 2025 22:37
@rudiejd rudiejd force-pushed the feat/replacement-service-api branch from 9c6aaeb to 6892dc3 Compare February 10, 2025 20:26
@@ -21,6 +21,12 @@ defmodule Arrow.Disruptions.ReplacementService do
shuttle: Shuttle.t() | Ecto.Association.NotLoaded.t()
}

@service_type_to_workbook_abbreviation %{
:weekday => "WKDY",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these felt like magic values to me, but I didn't want to mess with the parsing code too much so I just made service_types externally exposed as atoms.

@rudiejd rudiejd requested review from a team and Whoops and removed request for a team February 10, 2025 20:58
@rudiejd rudiejd marked this pull request as ready for review February 10, 2025 20:59
@rudiejd rudiejd force-pushed the feat/replacement-service-api branch from fa6e8b0 to dbb3288 Compare February 12, 2025 22:49
join: sr in assoc(s, :routes),
join: rs in assoc(sr, :route_stops),
left_join: gs in assoc(rs, :gtfs_stop),
left_join: st in assoc(rs, :stop),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Human whining about an interface meant for computers: I don't think we need the GTFS and Arrow stops themselves. We really only need the stop_id. GTFS stops are already in GTFS and GTFS Creator will already have any arrow managed stops by virtue of calling /api/shuttle-stops.

I also sort of hate how difficult JSON:API makes it for me as a human to make sense of the output, but I suppose that ship has sailed.

Copy link
Collaborator

@Whoops Whoops left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't appear to meet the requirements in the ticket. Unless I'm missing something this is encoding the database structures rather than generating the timetables as described.

@Whoops
Copy link
Collaborator

Whoops commented Feb 13, 2025

This doesn't appear to meet the requirements in the ticket. Unless I'm missing something this is encoding the database structures rather than generating the timetables as described.

Or I take that back, I think it is trying to. But my test shuttle is returning null timetables for all days. Looking deeper.

) do
service_type_abbreviation = Map.get(@service_type_to_workbook_abbreviation, service_type_atom)

if Map.has_key?(workbook_data, service_type_abbreviation) do
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Chasing my lack of timetables backwards, it looks like this if will never be true. The keys on the workbook are ["SAT headways and runtimes", "SUN headways and runtimes", "WKDY headways and runtimes", "version"], but your trying to look up SAT/SUN/WKDY.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

G35 Dec 6-20 Ops Summary2.xlsx is the workbook I'm testing with. For better or worse, it looks like the parsing code is strict about the sheet name when parsing, and uses the sheet name verbatim, so those are the keys that will always be there.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ahh good point! I missed adding the headways and runtimes part in

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.

3 participants