Skip to content

Compat w/ trip updates (status/schedule)#81

Draft
mmathieum wants to merge 12 commits intomasterfrom
mm/gtfs_rt_trip_updates
Draft

Compat w/ trip updates (status/schedule)#81
mmathieum wants to merge 12 commits intomasterfrom
mm/gtfs_rt_trip_updates

Conversation

@mmathieum
Copy link
Member

Fixes: #80

@mmathieum mmathieum self-assigned this Mar 2, 2026
@mmathieum mmathieum added the P1 ⏫ Priority 1: Highest label Mar 2, 2026
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the application's ability to provide accurate and timely public transportation information by integrating GTFS Realtime Trip Updates. It builds upon the existing GTFS Realtime infrastructure, adding new data fetching, processing, and caching capabilities specifically for real-time schedule changes. This ensures that users receive the most current schedule information, improving the overall reliability and user experience of the transit application.

Highlights

  • GTFS Realtime Trip Updates Integration: Introduced comprehensive support for GTFS Realtime Trip Updates, enabling the application to fetch and process real-time schedule changes for public transportation.
  • API and Data Model Extensions: Extended the GTFSRealTimeProvider to implement StatusProviderContract, added new URL handling for trip updates, and updated the Schedule data model with necessary accessors for filtering.
  • Database and Storage Updates: Modified the GTFS Realtime database schema to include a new 'status' table for trip updates and added storage mechanisms for tracking the last update time and status codes for trip update data.
  • Utility and Extension Functions: Developed new Kotlin extension functions in GtfsRealtimeExt.kt to facilitate the processing, filtering, and sorting of GTFS Realtime TripUpdate objects, and added StatusProviderExt.kt for simplified cached status retrieval.
Changelog
  • src/main/java/org/mtransit/android/commons/data/Schedule.java
    • Added getTargetAuthority(), getRouteId(), and getDirectionId() methods to the ScheduleStatusFilter class to provide access to relevant schedule filtering parameters.
  • src/main/java/org/mtransit/android/commons/provider/GTFSRealTimeProvider.java
    • Implemented StatusProviderContract to integrate trip update status management.
    • Added static methods getAgencyTripUpdatesUrlString, getAGENCY_TRIP_UPDATES_URL, and getAGENCY_TRIP_UPDATES_URL_CACHED for managing GTFS Realtime Trip Updates URLs.
    • Overrode various status-related methods (getStatusMaxValidityInMs, getNewStatus, cacheStatus, etc.) to handle trip update data.
    • Updated GTFSRealTimeDbHelper to include a new T_GTFS_REAL_TIME_TRIP_UPDATES table and its corresponding SQL creation/drop statements.
    • Incremented the database version and updated onUpgradeMT and initAllDbTables to manage the new status table.
  • src/main/java/org/mtransit/android/commons/provider/gtfs/GtfsRealTimeStorage.kt
    • Added PREF_KEY_TRIP_UPDATE_LAST_UPDATE_MS and PREF_KEY_TRIP_UPDATE_LAST_UPDATE_CODE constants for storing trip update metadata.
    • Implemented getTripUpdateLastUpdateMs, saveTripUpdateLastUpdateMs, getTripUpdateLastUpdateCode, and saveTripUpdateLastUpdateCode functions for persistent storage of trip update information.
  • src/main/java/org/mtransit/android/commons/provider/gtfs/GtfsRealtimeExt.kt
    • Added extension functions toTripUpdates, toTripUpdatesWithIdPair, sortTripUpdates, and sortTripUpdatesPair for efficient handling of GTFS Realtime FeedEntity and TripUpdate lists.
    • Introduced toStringExt and opt extension properties for various GtfsRealtime.TripUpdate related classes to improve debugging and data access.
  • src/main/java/org/mtransit/android/commons/provider/status/GTFSRealTimeTripUpdatesProvider.kt
    • Added a new Kotlin file GTFSRealTimeTripUpdatesProvider.kt to encapsulate the logic for fetching, processing, and caching GTFS Realtime Trip Updates.
    • Defined constants for validity and refresh durations specific to trip updates.
    • Implemented methods for retrieving cached and new trip update statuses, including network requests, parsing of GTFS Realtime feed messages, and conversion to POIStatus objects.
    • Included robust error handling for network and data parsing failures.
  • src/main/java/org/mtransit/android/commons/provider/status/StatusProvider.java
    • Added a new static method deleteAllCachedStatus to allow for the complete removal of all cached statuses from the database.
  • src/main/java/org/mtransit/android/commons/provider/status/StatusProviderExt.kt
    • Added a new Kotlin file StatusProviderExt.kt providing extension functions for StatusProviderContract.
    • Implemented getCachedStatusS extension functions to simplify querying cached statuses based on target UUIDs and optional trip IDs.
    • Defined contentUri and dbTableName extension properties for StatusProviderContract for consistent URI and table name access.
  • src/main/res/values/gtfs_real_time_values.xml
    • Added new string resources gtfs_real_time_agency_trip_updates_url and gtfs_real_time_agency_trip_updates_url_cached to configure the URLs for GTFS Realtime Trip Updates.
Activity
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces support for GTFS Realtime Trip Updates to provide schedule status. The changes are quite extensive, touching the data layer, provider logic, and storage. While the overall structure seems to follow existing patterns for other GTFS-RT features, I've identified several critical and high-severity issues, primarily stemming from copy-paste errors from the vehicle positions implementation. These issues will likely cause compilation errors and prevent the feature from functioning as intended. Please review the detailed comments for specifics.

mmathieum and others added 11 commits March 4, 2026 14:55
…ealtimeExt.kt

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
…meProvider.java

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P1 ⏫ Priority 1: Highest

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Real-time 🛰️ next-departures" from GTFS-RT trip updates

1 participant