Skip to content

Commit

Permalink
Only perist vehicles with IsEntityInMessage=true (#114)
Browse files Browse the repository at this point in the history
This essentially makes the configuration value always true. See the
issue for context.
  • Loading branch information
jamespfennell committed Aug 23, 2023
1 parent 9db9070 commit 2de70cd
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 17 deletions.
5 changes: 1 addition & 4 deletions api/admin.proto
Original file line number Diff line number Diff line change
Expand Up @@ -293,10 +293,7 @@ message GtfsRealtimeOptions {
// stop multiple times.
bool reassign_stop_sequences = 4;

// If true, only process entities in a feed if the message contains
// the full entity. This is useful for cases where there are multiple
// feeds for the same system, and some feeds contain only partial
// information about entities.
// Deprecated: this field is ignored.
bool only_process_full_entities = 5;
}

Expand Down
5 changes: 1 addition & 4 deletions internal/gen/api/admin.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 1 addition & 6 deletions internal/update/realtime/realtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -649,22 +649,17 @@ func convertOptionalTime(in *time.Time) pgtype.Timestamptz {
}

func updateVehicles(ctx context.Context, updateCtx common.UpdateContext, vehicles []gtfs.Vehicle) error {
onlyProcessFullEntities := updateCtx.FeedConfig != nil &&
updateCtx.FeedConfig.GetGtfsRealtimeOptions().GetOnlyProcessFullEntities()
var validVehicleEntities []gtfs.Vehicle
for _, vehicle := range vehicles {
// Only insert vehicles that are in the feed.
if onlyProcessFullEntities && !vehicle.IsEntityInMessage {
if !vehicle.IsEntityInMessage {
continue
}

// Note: We can insert a vehicle with no ID if it has an associated
// trip, per the GTFS-realtime spec. For now, we'll just skip them.
if vehicle.GetID().ID == "" {
updateCtx.Logger.DebugCtx(ctx, "Vehicle has no ID or empty ID")
continue
}

validVehicleEntities = append(validVehicleEntities, vehicle)
}

Expand Down
3 changes: 0 additions & 3 deletions systems/us-ny-nycbus.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ feeds:
url: "https://gtfsrt.prod.obanyc.com/tripUpdates?key={{ .Args.mta_bus_api_key }}"
gtfsRealtimeOptions:
reassignStopSequences: true
onlyProcessFullEntities: true

- id: "alerts"
type: GTFS_REALTIME
Expand All @@ -39,5 +38,3 @@ feeds:
- id: "vehicles"
type: GTFS_REALTIME
url: "http://gtfsrt.prod.obanyc.com/vehiclePositions?key={{ .Args.mta_bus_api_key }}"
gtfsRealtimeOptions:
onlyProcessFullEntities: true

0 comments on commit 2de70cd

Please sign in to comment.