Skip to content

Commit

Permalink
fix(orca-fares): remove fare attributes with no rules
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-heppner-ibigroup committed Sep 25, 2024
1 parent 1c858c8 commit 0a95a2d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ protected void fillFareRules(
FareRuleSet fareRule = fareRuleSet.get(id);
if (fareRule == null) {
// Should never happen by design
LOG.error("Inexistant fare ID in fare rule: " + id);
LOG.error("Nonexistent fare ID in fare rule: " + id);
continue;
}
String contains = rule.getContainsId();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ public FareService makeFareService() {
@Override
public void processGtfs(FareRulesData fareRuleService, OtpTransitService transitService) {
fillFareRules(fareRuleService.fareAttributes(), fareRuleService.fareRules(), regularFareRules);
// ORCA agencies don't rely on fare attributes without rules, so let's remove them.
regularFareRules.entrySet().removeIf(entry -> !entry.getValue().hasRules());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,15 @@ public Set<RouteOriginDestination> getRouteOriginDestinations() {
return routeOriginDestinations;
}

public boolean hasRules() {
return (
!routes.isEmpty() ||
!originDestinations.isEmpty() ||
!routeOriginDestinations.isEmpty() ||
!contains.isEmpty()
);
}

public void addContains(String containsId) {
contains.add(containsId);
}
Expand Down

0 comments on commit 0a95a2d

Please sign in to comment.