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

Add a matcher API for filters in the transit service used for route lookup #6378

Open
wants to merge 2 commits into
base: dev-2.x
Choose a base branch
from

Conversation

eibakke
Copy link
Contributor

@eibakke eibakke commented Jan 10, 2025

Summary

This change allows for a clean separation of concerns and lays the path for more efficient filtering logic down the line.

The functionality is backwards compatible, though there may be a discussion here that it should not be and that we should instead improve on some of the choices made earlier. For instance whether the longName check should really be a case insensitive prefix match.

Issue

#5630

Unit tests

Added unit tests for each matcher and the new RegularStopMatcherFactory. Also ensured that the API in local runs behaves as expected.

Documentation

Added JavaDoc.

@eibakke eibakke requested a review from a team as a code owner January 10, 2025 13:31
Copy link

codecov bot commented Jan 10, 2025

Codecov Report

Attention: Patch coverage is 71.55172% with 33 lines in your changes missing coverage. Please review.

Project coverage is 69.85%. Comparing base (025e4c4) to head (8475207).
Report is 3 commits behind head on dev-2.x.

Files with missing lines Patch % Lines
...anner/apis/transmodel/TransmodelGraphQLSchema.java 40.90% 26 Missing ⚠️
...planner/transit/service/DefaultTransitService.java 0.00% 3 Missing ⚠️
...t/java/org/opentripplanner/ext/flex/FlexIndex.java 0.00% 1 Missing ⚠️
...ilter/expr/CaseInsensitiveStringPrefixMatcher.java 85.71% 1 Missing ⚠️
...nsit/model/filter/expr/NullSafeWrapperMatcher.java 85.71% 1 Missing ⚠️
...nsit/model/filter/transit/RouteMatcherFactory.java 95.00% 1 Missing ⚠️
Additional details and impacted files
@@              Coverage Diff              @@
##             dev-2.x    #6378      +/-   ##
=============================================
+ Coverage      69.80%   69.85%   +0.04%     
- Complexity     17943    17977      +34     
=============================================
  Files           2046     2051       +5     
  Lines          76671    76731      +60     
  Branches        7830     7827       -3     
=============================================
+ Hits           53521    53599      +78     
+ Misses         20408    20389      -19     
- Partials        2742     2743       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Comment on lines +200 to +202
public Collection<Route> getRoutes(Collection<FeedScopedId> id) {
return id.stream().map(this::getRoute).filter(Objects::nonNull).toList();
}
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
public Collection<Route> getRoutes(Collection<FeedScopedId> id) {
return id.stream().map(this::getRoute).filter(Objects::nonNull).toList();
}
public Collection<Route> getRoutes(Collection<FeedScopedId> ids) {
return ids.stream().map(this::getRoute).filter(Objects::nonNull).toList();
}

Copy link
Member

Choose a reason for hiding this comment

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

Sorry was a bit confused by the variable name.

Comment on lines +39 to +50
new I18NString() {
@Override
public String toString() {
return "ROUTE1LONG";
}

@Override
public String toString(Locale locale) {
return "ROUTE1LONG";
}
}
)
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
new I18NString() {
@Override
public String toString() {
return "ROUTE1LONG";
}
@Override
public String toString(Locale locale) {
return "ROUTE1LONG";
}
}
)
I28NString.of("ROUTE1")

What is the reason you went for your own implementation?

Comment on lines +65 to +75
new I18NString() {
@Override
public String toString() {
return "ROUTE2LONG";
}

@Override
public String toString(Locale locale) {
return "ROUTE2LONG";
}
}
Copy link
Member

Choose a reason for hiding this comment

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

Same here.

Comment on lines +56 to +60
Agency
.of(new FeedScopedId("otherFeedId", "otherAgencyId"))
.withName("OTHER_AGENCY")
.withTimezone("Europe/Oslo")
.build()
Copy link
Member

Choose a reason for hiding this comment

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

You may find TimetableRepositoryForTest.agency useful.

Copy link
Member

@leonardehrenfried leonardehrenfried left a comment

Choose a reason for hiding this comment

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

The main code looks very neat but I have a few comments about the test code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants