Skip to content

Conversation

@lemald
Copy link
Member

@lemald lemald commented Jan 20, 2026

Summary of changes

Asana Ticket: part of 🏹🚆 Schedule View

Screenshot 2026-01-20 at 15 18 28

This change handles the basics of rendering the schedule into a tabular timetable view, while also allowing toggling between different routes and directions within the same export. The page is still not linked directly from the Trainsformer export section, but you can manually navigate to /trainsformer_exports/[export ID]/timetable in your browser to look at the rendered result.

Note that I am aware that the ordering of the stops when not all trips have the same stopping pattern isn't great. I think improving that will be for a followup PR / subtask.

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.

@lemald lemald marked this pull request as ready for review January 20, 2026 20:27
@lemald lemald requested a review from a team as a code owner January 20, 2026 20:27
@lemald lemald requested review from rudiejd and removed request for a team January 20, 2026 20:27
@lemald
Copy link
Member Author

lemald commented Jan 21, 2026

Re: changes to add the link from the view disruption page - we don't really have any existing tests as far as I can tell for the display of the view trainsformer export details section, so I'm not sure how to best test my change. Suggestions welcome.

</th>
</tr>
<% end %>
</thead>
Copy link
Member

Choose a reason for hiding this comment

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

nice! I always forget the thead / tbody tags

assert response =~ "SPRING2025-SOUTHSS-Weekend-66"
assert response =~ "CR-Foxboro"
assert response =~ "Back Bay"
assert response =~ "10:50:00"
Copy link
Member

@rudiejd rudiejd Jan 22, 2026

Choose a reason for hiding this comment

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

could you also test clicking the route / direction here, or would that be better in an integration test? would it make more sense to test an export with more than one route?

Enum.reduce(all_schedules, [], fn trip_data, stop_ids ->
unseen_stop_ids =
trip_data.stop_times
|> Enum.map(& &1.stop_id)
Copy link
Member

Choose a reason for hiding this comment

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

You could do this in a single pass of stop_times with Enum.reduce. Also, would it be worth making stop IDs ito a MapSet here?

all_schedules =
schedule_data
|> Map.get(service_id)
|> Enum.map(fn {_trip_id, trip_data} -> trip_data end)
Copy link
Member

Choose a reason for hiding this comment

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

This map and reduce could also be combined into a single pass. I'm not sure if mix and/or BEAM do this by default, in which case it's just a matter of taste

train_numbers = Enum.map(all_schedules, & &1.short_name)

# Combine stop names and stop times into rows
stop_times_by_stop =
Copy link
Member

Choose a reason for hiding this comment

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

could you utilize Enum.group_by/3 here?

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