GTFS-RT Trip Updates > fix static data used too small. - #184
Conversation
Max 3 days is not enough to make sure we always have 2 next departures (incl. far away static) (bug of Friday PM with routes service ending on Friday before Week-End breaks)
|
Warning Review limit reached
Next review available in: 26 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughGTFS status defaults now reference a shared request limit. Real-time trip updates use UUID-based schedule selection, while schedule caching retains timestamp filtering and metadata updates with renamed parameters and clearer conditions. ChangesGTFS status and real-time schedule updates
Estimated code review effort: 2 (Simple) | ~10 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/main/java/org/mtransit/android/commons/provider/status/GTFSRealTimeTripUpdatesProviderExt.kt (1)
55-68: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick winRestore a per-trip index before iterating updates.
Each trip update repeatedly scans all static timestamps to find matching schedules. With the expanded static window, this becomes
tripUpdates × schedules × timestamps; precompute trip ID → RDS UUIDs once and reuse it.Proposed refactor
val rdSchedulesByUUID = rdSchedules.associateBy { it.targetUUID } +val rdsUUIDsByTripId = mutableMapOf<String, MutableSet<String>>() +rdSchedulesByUUID.forEach { (uuid, schedule) -> + schedule.timestamps.mapNotNull { it.tripId }.forEach { tripId -> + rdsUUIDsByTripId.getOrPut(tripId) { mutableSetOf() }.add(uuid) + } +} rdTripUpdates.forEach { (td, gTripUpdate) -> val gTripId = td.optTripIdNotEmpty ?: return@forEach val tripId = parseTripId(gTripId) - if (rdSchedulesByUUID.none { (_, schedule) -> schedule.timestamps.any { it.tripId == tripId } }) - return@forEach // trip ID not in static data - val tripRdsUUIDs = rdSchedulesByUUID - .filter { (_, schedule) -> schedule.timestamps.any { it.tripId == tripId } } - .keys + val tripRdsUUIDs = rdsUUIDsByTripId[tripId] ?: return@forEach + val tripSchedules = tripRdsUUIDs.mapNotNull { rdSchedulesByUUID[it] } // ... - val sortedTargetUuidAndSequence = makeTargetUuidAndSequenceList(tripId, rdSchedulesByUUID.values, tripSortedRDS) + val sortedTargetUuidAndSequence = makeTargetUuidAndSequenceList(tripId, tripSchedules, tripSortedRDS)🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/main/java/org/mtransit/android/commons/provider/status/GTFSRealTimeTripUpdatesProviderExt.kt` around lines 55 - 68, In the flow around rdSchedulesByUUID and the rdTripUpdates.forEach loop, precompute a tripId-to-RDS-UUID index from each schedule’s timestamps before iterating updates. Replace the repeated rdSchedulesByUUID scans used to validate the trip and build tripRdsUUIDs with lookups into this index, preserving the existing skip behavior when no matching static schedule exists.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In
`@src/main/java/org/mtransit/android/commons/provider/status/GTFSRealTimeTripUpdatesProviderExt.kt`:
- Around line 55-68: In the flow around rdSchedulesByUUID and the
rdTripUpdates.forEach loop, precompute a tripId-to-RDS-UUID index from each
schedule’s timestamps before iterating updates. Replace the repeated
rdSchedulesByUUID scans used to validate the trip and build tripRdsUUIDs with
lookups into this index, preserving the existing skip behavior when no matching
static schedule exists.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: db2c9dae-ae8e-43ee-8750-1484814e8560
📒 Files selected for processing (4)
src/main/java/org/mtransit/android/commons/data/Schedule.javasrc/main/java/org/mtransit/android/commons/provider/gtfs/GtfsStatusProviderExt.ktsrc/main/java/org/mtransit/android/commons/provider/status/GTFSRealTimeTripUpdatesProvider.ktsrc/main/java/org/mtransit/android/commons/provider/status/GTFSRealTimeTripUpdatesProviderExt.kt
There was a problem hiding this comment.
Pull request overview
This PR increases the amount of static schedule data fetched/used when processing GTFS-RT Trip Updates so that real-time matching can still yield at least a couple upcoming departures even when the next scheduled service is farther in the future (e.g., weekend gaps). It also refactors parts of the trip-update processing/caching pipeline for clarity.
Changes:
- Refactored trip-update processing to pre-index schedules by UUID and map trip IDs to the set of relevant stop UUIDs.
- Updated schedule caching helper signature/variable naming and clarified timestamp partition handling.
- Aligned the GTFS static schedule fetch defaults with
ScheduleStatusFilter.MAX_DATA_REQUESTS_DEFAULTto avoid too-small static windows.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| src/main/java/org/mtransit/android/commons/provider/status/GTFSRealTimeTripUpdatesProviderExt.kt | Refactors trip-to-static-schedule matching/indexing used during trip update processing. |
| src/main/java/org/mtransit/android/commons/provider/status/GTFSRealTimeTripUpdatesProvider.kt | Renames/cleans up real-time schedule caching parameters and timestamp window logic. |
| src/main/java/org/mtransit/android/commons/provider/gtfs/GtfsStatusProviderExt.kt | Increases default static schedule request window by using ScheduleStatusFilter.MAX_DATA_REQUESTS_DEFAULT. |
| src/main/java/org/mtransit/android/commons/data/Schedule.java | Adds a brief clarifying comment about the Schedule’s conceptual mapping. |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (1)
src/main/java/org/mtransit/android/commons/provider/status/GTFSRealTimeTripUpdatesProviderExt.kt:136
processRDTripUpdatenow callssetTripDeleted/setTripCancelledonrdSchedulesByUUID.values(all schedules), even though only the schedules for the current trip can possibly be affected. This adds unnecessary iteration and makes the parameter name easy to misread as “trip-only”. You can derive the trip schedules fromsortedTargetUuidAndSequence(already computed for this trip) and only update those.
val gTripUpdateReadFromSourceMs = gTripUpdate.optTimestampMs ?: feedReadFromSourceMs
if (gTripUpdate.optTrip?.optScheduleRelationship == GTDScheduleRelationship.DELETED) {
rdSchedulesByUUID.values.setTripDeleted(tripId, gTripUpdateReadFromSourceMs)
return
}
if (gTripUpdate.optTrip?.optScheduleRelationship == GTDScheduleRelationship.CANCELED) {
rdSchedulesByUUID.values.setTripCancelled(tripId, includeCancelledTimestamps, gTripUpdateReadFromSourceMs)
return
…parser': - commons: Initialize .coderabbit.yaml with review settings mtransitapps/commons#830 - commons: Add `.coderabbit.yaml` configuration mtransitapps/commons#829 - commons: Update maps dependencies mtransitapps/commons#826 - commons: Update Kotlin from `2.3.21` to `2.4.10` mtransitapps/commons#827 - commons: Update Hilt from `2.59.2` to `2.60.1` mtransitapps/commons#828 - commons: Update Protobuf from `4.34.1` to `4.35.1` mtransitapps/commons#825 - commons: Update OkHttp from `5.3.2` to `5.4.0` mtransitapps/commons#824 - commons: Update Glide version from `5.0.7` to `5.0.9` mtransitapps/commons#823 - commons: Bump org.xerial:sqlite-jdbc from 3.53.0.0 to 3.53.2.0 mtransitapps/commons#822 - commons: Build(deps): Bump android-gradlePlugin from 9.3.0 to 9.3.1 mtransitapps/commons#821 - commons: Use `git update-index --skip-worktree` to hide locally changed "key" files mtransitapps/commons#820 - commons: Build(deps): Bump com.google.android.libraries.ads.mobile.sdk:ads-mobile-sdk from 1.2.1 to 1.3.0 mtransitapps/commons#819 - commons-android: GTFS-RT Trip Updates > fix static data used too small. mtransitapps/commons-android#184 - commons-android: Add configuration for auto review in coderabbit - commons-android: Merge branch 'master' of github.com:mtransitapps/commons-android - commons-android: suppress deprecated GTFS-RT vehicle location trip descriptor schedule relationship added - commons-android: tests++ - commons-android: Ignore far away vehicles locations mtransitapps/commons-android#181 - commons-android: GTFS-RT Trip Update schedule status > fix wrong 1 min `validity` mtransitapps/commons-android#180 - commons-java: Add initial configuration for coderabbit reviews - commons-java: Source labels > ignore "gtfsapi" #TransLink - parser: Add .coderabbit.yaml configuration file - parser: Auto enable direction splitter when `trips.txt` doesn't have `direction_id` column mtransitapps/parser#82 - parser: `JSON` > `use_route_long_name_for_route_short_name` > use RSN cleaners
…parser': - commons: Initialize .coderabbit.yaml with review settings mtransitapps/commons#830 - commons: Add `.coderabbit.yaml` configuration mtransitapps/commons#829 - commons: Update maps dependencies mtransitapps/commons#826 - commons: Update Kotlin from `2.3.21` to `2.4.10` mtransitapps/commons#827 - commons: Update Hilt from `2.59.2` to `2.60.1` mtransitapps/commons#828 - commons: Update Protobuf from `4.34.1` to `4.35.1` mtransitapps/commons#825 - commons: Update OkHttp from `5.3.2` to `5.4.0` mtransitapps/commons#824 - commons: Update Glide version from `5.0.7` to `5.0.9` mtransitapps/commons#823 - commons: Bump org.xerial:sqlite-jdbc from 3.53.0.0 to 3.53.2.0 mtransitapps/commons#822 - commons: Build(deps): Bump android-gradlePlugin from 9.3.0 to 9.3.1 mtransitapps/commons#821 - commons: Use `git update-index --skip-worktree` to hide locally changed "key" files mtransitapps/commons#820 - commons: Build(deps): Bump com.google.android.libraries.ads.mobile.sdk:ads-mobile-sdk from 1.2.1 to 1.3.0 mtransitapps/commons#819 - commons-android: GTFS-RT Trip Updates > fix static data used too small. mtransitapps/commons-android#184 - commons-android: Add configuration for auto review in coderabbit - commons-android: Merge branch 'master' of github.com:mtransitapps/commons-android - commons-android: suppress deprecated GTFS-RT vehicle location trip descriptor schedule relationship added - commons-android: tests++ - commons-android: Ignore far away vehicles locations mtransitapps/commons-android#181 - commons-android: GTFS-RT Trip Update schedule status > fix wrong 1 min `validity` mtransitapps/commons-android#180 - commons-java: Add initial configuration for coderabbit reviews - commons-java: Source labels > ignore "gtfsapi" #TransLink - parser: Add .coderabbit.yaml configuration file - parser: Auto enable direction splitter when `trips.txt` doesn't have `direction_id` column mtransitapps/parser#82 - parser: `JSON` > `use_route_long_name_for_route_short_name` > use RSN cleaners
…parser': - commons: Initialize .coderabbit.yaml with review settings mtransitapps/commons#830 - commons-android: GTFS-RT Trip Updates > fix static data used too small. mtransitapps/commons-android#184 - commons-android: Add configuration for auto review in coderabbit - commons-java: Add initial configuration for coderabbit reviews - commons-java: Source labels > ignore "gtfsapi" #TransLink - parser: Add .coderabbit.yaml configuration file
…parser': - commons: Initialize .coderabbit.yaml with review settings mtransitapps/commons#830 - commons-android: GTFS-RT Trip Updates > fix static data used too small. mtransitapps/commons-android#184 - commons-android: Add configuration for auto review in coderabbit - commons-java: Add initial configuration for coderabbit reviews - commons-java: Source labels > ignore "gtfsapi" #TransLink - parser: Add .coderabbit.yaml configuration file
…parser': - commons: Initialize .coderabbit.yaml with review settings mtransitapps/commons#830 - commons-android: GTFS-RT Trip Updates > fix static data used too small. mtransitapps/commons-android#184 - commons-android: Add configuration for auto review in coderabbit - commons-java: Add initial configuration for coderabbit reviews - commons-java: Source labels > ignore "gtfsapi" #TransLink - parser: Add .coderabbit.yaml configuration file
…er': - commons: Initialize .coderabbit.yaml with review settings mtransitapps/commons#830 - commons: Add `.coderabbit.yaml` configuration mtransitapps/commons#829 - commons-android: GTFS-RT Trip Updates > fix static data used too small. mtransitapps/commons-android#184 - commons-android: Add configuration for auto review in coderabbit - commons-android: Merge branch 'master' of github.com:mtransitapps/commons-android - commons-android: suppress deprecated GTFS-RT vehicle location trip descriptor schedule relationship added - commons-android: tests++ - commons-android: Ignore far away vehicles locations mtransitapps/commons-android#181 - commons-java: Add initial configuration for coderabbit reviews - commons-java: Source labels > ignore "gtfsapi" #TransLink - parser: Add .coderabbit.yaml configuration file
…er': - commons: Initialize .coderabbit.yaml with review settings mtransitapps/commons#830 - commons: Add `.coderabbit.yaml` configuration mtransitapps/commons#829 - commons: Update maps dependencies mtransitapps/commons#826 - commons: Update Kotlin from `2.3.21` to `2.4.10` mtransitapps/commons#827 - commons: Update Hilt from `2.59.2` to `2.60.1` mtransitapps/commons#828 - commons: Update Protobuf from `4.34.1` to `4.35.1` mtransitapps/commons#825 - commons: Update OkHttp from `5.3.2` to `5.4.0` mtransitapps/commons#824 - commons: Update Glide version from `5.0.7` to `5.0.9` mtransitapps/commons#823 - commons: Bump org.xerial:sqlite-jdbc from 3.53.0.0 to 3.53.2.0 mtransitapps/commons#822 - commons: Build(deps): Bump android-gradlePlugin from 9.3.0 to 9.3.1 mtransitapps/commons#821 - commons: Use `git update-index --skip-worktree` to hide locally changed "key" files mtransitapps/commons#820 - commons: Build(deps): Bump com.google.android.libraries.ads.mobile.sdk:ads-mobile-sdk from 1.2.1 to 1.3.0 mtransitapps/commons#819 - commons: Target SDK `36` (Android 16) before Aug 31, 2026 mtransitapps/commons#817 - commons: Create `.aiexclude` to manage AI file exclusions mtransitapps/commons#816 - commons: Allow `download()` user-agent override via `MT_DOWNLOAD_USER_AGENT` mtransitapps/commons#815 - commons: Build(deps): Bump android-gradlePlugin from 9.2.1 to 9.3.0 mtransitapps/commons#814 - commons: Fix `mt-record-screenshots.yml` #810 - commons: Switch latest APK fetch to `gh release download` and pick first APK artifact mtransitapps/commons#810 - commons: Build(deps): Bump com.google.ads.mediation:facebook from 6.21.0.3 to 6.21.0.4 in the ads group across 1 directory mtransitapps/commons#813 - commons: Build(deps): Bump com.google.firebase:firebase-bom from 34.15.0 to 34.16.0 in the gms group across 1 directory mtransitapps/commons#812 - commons: Build(deps): Bump com.google.devtools.ksp from 2.3.9 to 2.3.10 in the kotlin-ksp-compose group across 1 directory mtransitapps/commons#811 - commons: Gradle 9.4+ > enable parallel sync - commons: Skip GitHub release creation when existing release is already latest mtransitapps/commons#809 - commons: runall.sh > print current directory on failure - commons: Build(deps): Bump com.google.android.libraries.places:places from 5.2.0 to 5.3.0 mtransitapps/commons#808 - commons-android: GTFS-RT Trip Updates > fix static data used too small. mtransitapps/commons-android#184 - commons-android: Add configuration for auto review in coderabbit - commons-android: Merge branch 'master' of github.com:mtransitapps/commons-android - commons-android: suppress deprecated GTFS-RT vehicle location trip descriptor schedule relationship added - commons-android: tests++ - commons-android: Ignore far away vehicles locations mtransitapps/commons-android#181 - commons-android: GTFS-RT Trip Update schedule status > fix wrong 1 min `validity` mtransitapps/commons-android#180 - commons-android: GTFS-RT > Trip Updates > try to fix wrong stop sequence when trip stop passed once & keep all cancelled trips/stops mtransitapps/commons-android#178 - commons-android: Update SSL cert mtransitapps/commons-android#177 - commons-android: GTFS-RT > Trip Updates > handle wrong stop sequence w/o loosing all data mtransitapps/commons-android#176 - commons-android: GTFS-RT Trip Update > fix same stop matching mtransitapps/commons-android#175 - commons-android: suppress - commons-android: GTFS-RT > Trip filtering > allow ignore `direction_id` when `trip_id` is provided mtransitapps/commons-android#172 - commons-android: Status > `hasData` != `!noData` ('no data' means loaded w/o data) mtransitapps/commons-android#173 - commons-android: #isAndroidApp cleanup - commons-java: Add initial configuration for coderabbit reviews - commons-java: Source labels > ignore "gtfsapi" #TransLink - commons-java: String utils > "and" -> "&" always (tests) - commons-java: String utils > "and" -> "&" always - commons-java: Add build-time `MT_DEBUG_DEFAULT` support for `Constants.DEBUG` mtransitapps/commons-java#45 - commons-java: Replace `(?U)` (no compat /w Android) with Unicode Property Classes like `\p{L}`. - commons-java: CRASH fix created 5 hours ago in 478717d - commons-java: regex scratch++ - parser: Add .coderabbit.yaml configuration file - parser: Auto enable direction splitter when `trips.txt` doesn't have `direction_id` column mtransitapps/parser#82 - parser: `JSON` > `use_route_long_name_for_route_short_name` > use RSN cleaners - parser: comment fix - parser: `JSON` > + `[keep/exclude]_routes`.`route_short_name_regex` #NRT mtransitapps/parser#79 - parser: Use GTFS directions file when provided #lio mtransitapps/parser#77
Max 3 days is not enough to make sure we always have 2 next departures (incl. far away static)
(bug of Friday PM with routes service ending on Friday before Week-End breaks)
Summary by CodeRabbit