Add Scheduled bus time arrivals #14
Labels
No labels
bug
contribution welcome
duplicate
enhancement
good first issue
help wanted
invalid
question
upstream
needs/docs
needs/research
needs/upstream
type/bug
type/external
type/feature
type/refactor
urgency
high
urgency
immediate
urgency
low
urgency
medium
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
ScottyLabs/bus-sign#14
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Objective
Sometimes a bus is scheduled at a time according to the PRT's timetable, but there is no live GPS tracking for it, so we don't get it from the API. We want to fill those gaps with timetable trips from PRT's General Transit Feed Specification (GTFS) feed, marked with the gray "Scheduled" badge.
Here's the design we are using. The font is grayed out, with a "Scheduled" badge next to the bus line. Note that we've already implemented this in

BusTimeEntry.svelte.Suggested Approach
Knowledge Prereqs
Become familiar with these resources:
backend/src/lib.rsin this project to see how we parse this data.Data Exploration
Investigate what is the best way to get scheduled arrivals such that it is in a machine-readable format and it is easy to resync when it changes. The GFTS dataset seems like the best source of scheduled times so far, but do some more research and see if there's anything else that might be useful/more convenient.
If we are using the GFTS dataset, we probably don't want to store a 100 MB file in the repo or our database. Maybe we want to request the zip from the website and keep only the important parts of it at compile-time? Which fields should we keep? What are some other ways to use this data? Ask yourselves these questions and consider the benefits/drawbacks if we decide to go a certain way.
Before continuing, please explain your findings and what you suggest to do in the bus sign discord channel, so you can get some feedback :D
Backend
You'll need to edit the backend so that it efficiently reads and parses the data. Maybe make a new file for this if it's a lot of code, and look online for any crates (packages) that might be helpful. For example, use the csv crate if we're storing the data as a csv, etc.
Next, update the backend so it responds to API requests with any upcoming scheduled arrival. This is done in
lib.rs. You'll probably want to edit theBusArrivalstruct so that it has thescheduled: boolfield, along with some other changes.Make sure that we prioritize live bus predictions over scheduled ones. We shouldn't have both at the same time (perhaps filter the vector of
BusArrivalsto do this).Frontend
You won't need to do a lot here, since we've already created the scheduled style, but you'll need to make some small edits so that this works with the new backend API. Update the
RouteInformation.arrivalstype in bothApp.svelteandBusList.svelte, and use theBusTimeEntrycomponent withscheduled=trueto display a scheduled bus arrival.Scheduled rows should be sorted below live ones that are in the same minute (edit the
sortByArrivalfunction inApp.svelteif it doesn't do this).Note to contributors
Take your time with this. While AI can probably one-shot the code, PLEASE try to do it by yourself for the learning experience. Try to use AI to explain things, not write code for you.
This video tutorial is lengthy, but it assumes no prior Rust experience. The first 20 minutes are dedicated purely to giving an overview Rust. The remaining parts of the video go over
Axum, the web app framework we use.You can also find resources linked on the CMU course 98-008: Intro to Rust Lang! Click on the materials dropdown of each lecture in the Schedules page (shameless plug)
The frontend should be a bit easier to pick up, but if you'd like, check out the official Svelte tutorial!