-
Notifications
You must be signed in to change notification settings - Fork 15
verifiy-arrivals-and-departures-for-stop-94 #164
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
base: main
Are you sure you want to change the base?
Conversation
fix: change arrival and departure time to seconds only from trips_helper
Tests were failing because they used time.Now() which is now beyond the RABA test data's calendar range (ending 2025-12-31). Adding an explicit date parameter ensures tests use a date with active services.
fix: add explicit date param to schedule handler tests
Fix gtfstidy import
aaronbrethorst
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice work. I see a couple things to address before this can be merged.
Issues to Fix
1. Branch needs rebasing onto latest main
The test TestScheduleForRouteHandler/Valid_route is failing, but this isn't caused by your changes. The main branch received a fix in PR #173 that adds a required date parameter to this test. You'll need to rebase your branch onto the latest main:
git fetch origin main
git rebase origin/main2. Missing test coverage for the new functionality
The linked issue #94 specifically asks for strengthening unit tests when coverage is missing. The changes add logic for:
distanceFromStopcalculation viagetBlockDistanceToStop()numberOfStopsAwaycalculation viagetNumberOfStopsAway()- Stop
Directionfield now usingcalculateStopDirection()
However, the existing tests don't verify these values are calculated correctly. Consider adding test assertions that check:
// Example additions to TestArrivalsAndDeparturesForStopHandlerEndToEnd
if distanceFromStop, ok := firstArrival["distanceFromStop"].(float64); ok {
// Verify it's a reasonable value when vehicle data is present
assert.GreaterOrEqual(t, distanceFromStop, 0.0)
}
if numberOfStopsAway, ok := firstArrival["numberOfStopsAway"].(float64); ok {
// -1 is valid (unknown), otherwise should be non-negative
assert.GreaterOrEqual(t, numberOfStopsAway, -1.0)
}And for stop references:
for _, stop := range stops_ref {
stopMap := stop.(map[string]interface{})
direction := stopMap["direction"].(string)
// Direction should be a valid cardinal direction or "UNKNOWN"
validDirections := []string{"N", "NE", "E", "SE", "S", "SW", "W", "NW", "UNKNOWN"}
assert.Contains(t, validDirections, direction)
}Suggestions
Code organization consideration
The distance and stops-away calculation logic is now inside the if status != nil block. This means these metrics will only be populated when we have trip status data. If a vehicle has position data but we couldn't build a trip status (e.g., BuildTripStatus returns nil), these metrics won't be calculated.
Looking at the code flow, this seems intentional and matches the single-arrival handler behavior at arrival_and_departure_for_stop_handler.go:257-266. Just wanted to confirm this is the expected behavior.
Once you rebase onto main and the tests pass, this PR is good to go!
…/github.com/OneBusAway/maglev into verifiy-arrivals-and-departures-for-stop-94
Fix: #94