master<-dev#1447
Merged
Merged
Conversation
…#1446) * Batch bus-related queries to eliminate N+1 in GetStationsByLineIdList When transport_type=RailAndBus with many line_ids, the endpoint suffered from 100+ sequential DB queries for bus stop enrichment. This change batches all bus-related queries before the main loop: 1. Add get_bus_stops_near_stations using LATERAL JOIN + UNNEST to fetch all nearby bus stops in a single query instead of per-station calls 2. Pre-fetch all bus lines in one get_by_station_group_id_vec call 3. Merge bus company IDs into the Phase 2 company fetch 4. Add get_by_station_group_id_vec_no_types to LineRepository to skip unnecessary station_station_types JOIN when skip_types_join=true Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * Fix bus stop transport_type filter using DB value instead of proto value The LATERAL JOIN SQL hardcoded transport_type=2 (proto Bus value) instead of using the DB value (TransportType::Bus = 1). Changed to parameterized bind using TransportType::Bus as i32 to match the existing get_by_coordinates pattern. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * Fix bus line ordering and restore pass=1 exclusion in lines query - Revert lines query to use get_lines_by_station_group_id_vec (with station_station_types JOIN) to preserve pass=1 exclusion filtering. The _no_types variant incorrectly removed this filter. - Iterate nearby_bus_stops in distance order (not HashSet) when collecting bus lines to preserve deterministic ordering. - Use entry().or_insert() for bus_stop_by_line_cd so the first (closest) bus stop per line_cd wins instead of the last. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * Add ORDER BY to outer query in get_bus_stops_near_stations The LATERAL subquery's ORDER BY does not guarantee result ordering in the outer SELECT. Add explicit ORDER BY ic.source_g_cd, distance to ensure results are nearest-first per source station, which is required for the entry().or_insert() logic that picks the closest bus stop per line. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * Restore _no_types lines query with NOT EXISTS pass=1 filter Replace the LEFT JOIN to station_station_types with a NOT EXISTS subquery that preserves the pass=1 exclusion while avoiding the row multiplication from the JOIN. This gives the performance benefit of skipping the sst JOIN while maintaining correct pass filtering. A station is excluded only when all its sst records with non-null line_group_cd have pass=1 (i.e., no non-pass-through entry exists). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * Add missing e_status=0 filter on lines JOIN in get_bus_stops_near_stations The JOIN to the lines table was missing the active-status filter, which could include inactive/discontinued lines in bus stop results. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Contributor
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.