Skip to content

fix(search): exclude partial route ID name matches - #108

Open
steventeng2022 wants to merge 1 commit into
YetAnotherBusDeveloper:mainfrom
steventeng2022:codex/fix-issue-106
Open

steventeng2022 wants to merge 1 commit into
YetAnotherBusDeveloper:mainfrom
steventeng2022:codex/fix-issue-106

Conversation

@steventeng2022

Copy link
Copy Markdown
Contributor

Summary

  • Stop treating routeId as a fallback route name when the displayed and official names are empty.
  • Keep exact route ID matches searchable while excluding partial ID-only matches.

Closes #106

Validation

  • git diff --check passed.
  • Tests were not run.

@Av1anJay Av1anJay left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Hermes Agent Review

Verdict: Comment — the one-line change is correct and matches the intent of #106; two non-blocking notes below.

What I verified

  • _displayRouteName is only consumed for ranking (_RouteSearchRank.fromSummary line 107), never for display, so dropping the routeId fallback cannot blank out any UI text.
  • _matchTier still returns tier 3 on exact routeId == query, so exact ID search (e.g. TXG41) keeps working; only the removed tier-4 partial-ID path is affected.
  • Downstream empty-name handling was already in place: nameLength: routeName.isEmpty ? 9999 : ... and nameLengthGaps filters empty names, so '' does not skew lengthGap.
  • _routeSummaryFromPathRow already substitutes routeId into routeName when the API row's name is empty, so real API-backed summaries were not relying on this fallback for partial-ID matching.

Checks run

  • CI Build workflow run 39135683333 on 8d94be7 — success: Verify (flutter analyze + flutter test) pass, all platform builds pass.
  • git diff --check — clean.
  • Local flutter test / dart analyze were attempted but could not complete in a reasonable time on this review host (1 GB RAM, heavy swap thrash). Not reported as passing.

Non-blocking notes

  1. Missing regression test — no test exercises the branch this PR actually changes: a RouteSummary with both routeName and officialRouteName empty. Existing fixtures cover empty-name routes only through the comparator-equality test, which changes on both sides and therefore passes regardless of the fallback. Worth adding two asserts: empty-name route + exact routeId query → true, empty-name route + partial routeId query → false.
  2. Divergent duplicate — lib/screens/search_screen.dart:555 has a near-identical _displayRouteName that still returns route.routeId.trim(). It is used by _hasStrongRouteMatch, which also compares routeId explicitly, so behavior there is intentional — but the two copies now disagree. A shared helper with an explicit includeRouteIdFallback flag would prevent the next reader from "fixing" one of them into a bug.

Reviewed by Hermes Agent

Comment thread lib/core/route_search_ranking.dart

This branch has not been deployed

No deployments
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