Skip to content
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

fix: don't include non-revenue trips in feeds #323

Merged
merged 2 commits into from
Dec 4, 2023
Merged

Conversation

Whoops
Copy link
Collaborator

@Whoops Whoops commented Nov 3, 2023

Summary of changes

Asana Ticket: 🧠 Concentrate suppresses non-revenue trips until December 7

Note: We will shortly want to start exposing non-revenue trips in the enhanced feed. This implementation is chosen to make that update trivial.

@Whoops Whoops requested review from a team and meagharty November 3, 2023 19:49
Copy link

github-actions bot commented Nov 3, 2023

Coverage of commit 2db12cf

Summary coverage rate:
  lines......: 93.3% (1388 of 1488 lines)
  functions..: 83.1% (446 of 537 functions)
  branches...: no data found

Files changed coverage rate:
                                                                    |Lines       |Functions  |Branches    
  Filename                                                          |Rate     Num|Rate    Num|Rate     Num
  ========================================================================================================
  lib/concentrate/encoder/gtfs_realtime_helpers.ex                  |98.2%     56|94.4%    18|    -      0
  lib/concentrate/encoder/trip_updates.ex                           | 100%      9| 100%     3|    -      0
  lib/concentrate/encoder/trip_updates_enhanced.ex                  | 100%      6| 100%     4|    -      0

Download coverage report

@Whoops Whoops requested a review from a team November 20, 2023 20:20
Copy link

Coverage of commit 1668a38

Summary coverage rate:
  lines......: 93.3% (1388 of 1488 lines)
  functions..: 83.1% (446 of 537 functions)
  branches...: no data found

Files changed coverage rate:
                                                                    |Lines       |Functions  |Branches    
  Filename                                                          |Rate     Num|Rate    Num|Rate     Num
  ========================================================================================================
  lib/concentrate/encoder/gtfs_realtime_helpers.ex                  |98.2%     56|94.4%    18|    -      0
  lib/concentrate/encoder/trip_updates.ex                           | 100%      9| 100%     3|    -      0
  lib/concentrate/encoder/trip_updates_enhanced.ex                  | 100%      6| 100%     4|    -      0

Download coverage report

@Whoops Whoops marked this pull request as draft November 20, 2023 21:12
Copy link

Coverage of commit 4d04f32

Summary coverage rate:
  lines......: 93.1% (1398 of 1502 lines)
  functions..: 80.6% (449 of 557 functions)
  branches...: no data found

Files changed coverage rate:
                                                                    |Lines       |Functions  |Branches    
  Filename                                                          |Rate     Num|Rate    Num|Rate     Num
  ========================================================================================================
  lib/concentrate/encoder/gtfs_realtime_helpers.ex                  |98.2%     56|94.4%    18|    -      0
  lib/concentrate/encoder/trip_updates.ex                           | 100%      9| 100%     3|    -      0
  lib/concentrate/encoder/trip_updates_enhanced.ex                  | 100%      6| 100%     4|    -      0
  lib/concentrate/encoder/vehicle_positions_enhanced.ex             |93.3%     15|83.3%     6|    -      0
  lib/concentrate/parser/gtfs_realtime_enhanced.ex                  |97.6%     82| 100%    17|    -      0
  lib/concentrate/trip_descriptor.ex                                |85.0%     20|74.2%    31|    -      0

Download coverage report

@Whoops Whoops marked this pull request as ready for review November 27, 2023 22:08
@Whoops
Copy link
Collaborator Author

Whoops commented Nov 27, 2023

This has been updated to use the (soon to be) newly added revenue field in RTR rather than filtering on trip_id.

Copy link

Coverage of commit ff57584

Summary coverage rate:
  lines......: 93.1% (1397 of 1501 lines)
  functions..: 80.6% (449 of 557 functions)
  branches...: no data found

Files changed coverage rate:
                                                                    |Lines       |Functions  |Branches    
  Filename                                                          |Rate     Num|Rate    Num|Rate     Num
  ========================================================================================================
  lib/concentrate/encoder/gtfs_realtime_helpers.ex                  |98.1%     53|94.4%    18|    -      0
  lib/concentrate/encoder/trip_updates.ex                           | 100%      9| 100%     3|    -      0
  lib/concentrate/encoder/trip_updates_enhanced.ex                  | 100%      6| 100%     4|    -      0
  lib/concentrate/encoder/vehicle_positions.ex                      |94.7%     19|85.7%     7|    -      0
  lib/concentrate/encoder/vehicle_positions_enhanced.ex             |93.8%     16|83.3%     6|    -      0
  lib/concentrate/parser/gtfs_realtime_enhanced.ex                  |97.6%     82| 100%    17|    -      0
  lib/concentrate/trip_descriptor.ex                                |85.0%     20|74.2%    31|    -      0

Download coverage report

%{route_pattern_id: TripDescriptor.route_pattern_id(update)}
%{
route_pattern_id: TripDescriptor.route_pattern_id(update),
revenue: TripDescriptor.revenue(update)
Copy link
Member

Choose a reason for hiding this comment

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

suggestion: given that true is the default, what about only including it when the value is false?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

If you feel strongly about it, I can. My main hesitation is that in nil ~ falsey languages, the naive interpretation is the opposite of what we actually mean. I'd tend to argue there shouldn't be a default, but maintaining current behavior on existing feeds kind of forces our hand there.

Copy link
Member

Choose a reason for hiding this comment

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

As you note, existing clients which care about this value will need to treat a missing value as true (as it was true for all trips before). But I don't think it needs to block the PR.

@@ -19,7 +21,7 @@ defmodule Concentrate.Encoder.VehiclePositionsEnhanced do
end

def build_entity({%TripDescriptor{} = td, vps, _stus}) do
trip = trip_descriptor(td)
trip = trip_descriptor(td) |> Map.put("revenue", TripDescriptor.revenue(td))
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
trip = trip_descriptor(td) |> Map.put("revenue", TripDescriptor.revenue(td))
trip = td
|> trip_descriptor()
|> Map.put("revenue", TripDescriptor.revenue(td))

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We might want to consider turning on Credo's PipeChainStart check. It's explicitly off at the moment.

Copy link
Member

Choose a reason for hiding this comment

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

It wasn't originally: 7032149

It looks like the default changed when we re-built the .credo.exs: c51fabf

Copy link

Coverage of commit d3ef98e

Summary coverage rate:
  lines......: 93.1% (1397 of 1501 lines)
  functions..: 80.6% (449 of 557 functions)
  branches...: no data found

Files changed coverage rate:
                                                                    |Lines       |Functions  |Branches    
  Filename                                                          |Rate     Num|Rate    Num|Rate     Num
  ========================================================================================================
  lib/concentrate/encoder/gtfs_realtime_helpers.ex                  |98.1%     53|94.4%    18|    -      0
  lib/concentrate/encoder/trip_updates.ex                           | 100%      9| 100%     3|    -      0
  lib/concentrate/encoder/trip_updates_enhanced.ex                  | 100%      6| 100%     4|    -      0
  lib/concentrate/encoder/vehicle_positions.ex                      |94.7%     19|85.7%     7|    -      0
  lib/concentrate/encoder/vehicle_positions_enhanced.ex             |93.8%     16|83.3%     6|    -      0
  lib/concentrate/parser/gtfs_realtime_enhanced.ex                  |97.6%     82| 100%    17|    -      0
  lib/concentrate/trip_descriptor.ex                                |85.0%     20|74.2%    31|    -      0

Download coverage report

@Whoops Whoops merged commit df0eaab into master Dec 4, 2023
3 checks passed
@Whoops Whoops deleted the wh-non-revenue-trips branch December 4, 2023 15:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants