Skip to content

Commit

Permalink
include delay in Departure and cli output
Browse files Browse the repository at this point in the history
  • Loading branch information
matslina committed Dec 25, 2023
1 parent 68eb51f commit f62fdd3
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 3 deletions.
6 changes: 5 additions & 1 deletion cmd/departures.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,11 @@ func departures(cmd *cobra.Command, args []string) error {
}

for _, departure := range departures {
fmt.Printf("%s %s %s\n", departure.RouteID, departure.Time, departure.Headsign)
line := fmt.Sprintf("%s %s %s", departure.RouteID, departure.Time, departure.Headsign)
if departure.Delay != 0 {
line += fmt.Sprintf(" (%s)", departure.Delay)
}
fmt.Println(line)
}

return nil
Expand Down
2 changes: 0 additions & 2 deletions downloader/downloader.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ func HTTPGet(ctx context.Context, url string, headers map[string]string, options

defer resp.Body.Close()

fmt.Println("status", resp.StatusCode)

var reader io.Reader = resp.Body
if options.MaxSize > 0 {
reader = io.LimitReader(resp.Body, int64(options.MaxSize))
Expand Down
1 change: 1 addition & 0 deletions realtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ func (rt *Realtime) Departures(
case parse.StopTimeUpdateScheduled:
// SCHEDULED => update to static schedule
dep.Time = dep.Time.Add(updates[idx].DepartureDelay)
dep.Delay = updates[idx].DepartureDelay
departures = append(departures, dep)
}
}
Expand Down
1 change: 1 addition & 0 deletions static.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ type Departure struct {
DirectionID int8
Time time.Time
Headsign string
Delay time.Duration
}

// Translates a time offset into a GTFS style HHMMSS string.
Expand Down

0 comments on commit f62fdd3

Please sign in to comment.