Skip to content

Conversation

@mmathieum
Copy link
Member

@mmathieum mmathieum self-assigned this Jan 15, 2026
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @mmathieum, 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 performs a significant cleanup and refactoring across the database utility, SQL escaping, and data generation components of the project. The changes aim to improve the robustness of SQL query construction, introduce more precise handling of SQL identifiers, and enhance the flexibility and efficiency of data serialization, particularly for schedule and service date information. These updates lay a foundation for future data processing and export capabilities, potentially related to vehicle data.

Highlights

  • SQL Query Construction Improvement: Refactored insertStopTime to use 0-based indexing with pre-increment (++idx) for prepared statement parameters, and streamlined conditional WHERE/AND clause generation in selectSchedules and deleteSchedules for conciseness.
  • Enhanced SQL Identifier Escaping: Introduced new escapeId() and quotesEscapeId() utility functions in SQLUtils.kt specifically for escaping SQL identifiers, and updated various GCalendar, GCalendarDate, MServiceId, MTripId, MServiceIds, and MTripIds usages to leverage this new identifier-specific escaping.
  • Refactored Data Sorting and File Output: Updated MServiceDate and MSchedule sorting logic to use dedicated comparators (COMPARATOR_BY_CALENDAR_DATE, COMPARATOR_FOR_FILE) and compareBy for better clarity and flexibility. The file output for service dates and schedules now supports conditional flattening and sorting based on new feature flags, and uses try-with-resources for BufferedWriter for improved resource management.
  • Feature Flag Integration: Integrated new feature flags (F_EXPORT_FLATTEN_SERVICE_DATES, F_EXPORT_SCHEDULE_SORTED_BY_ROUTE_DIRECTION) to control the output format and sorting behavior of generated data files, allowing for more flexible data exports.
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 a series of cleanups and refactorings across the codebase. Key changes include the introduction of a new escapeId function for SQL identifiers, which is now used consistently. The MServiceDate and MSchedule classes have been improved to use Comparators for sorting, which is a good practice. The use of try-with-resources in MGenerator.java is a welcome improvement for resource management.

My main feedback is on the dynamic SQL query construction in DBUtils.kt. While the current changes make the code more compact, they reduce readability. I've suggested a more significant refactoring to make this logic cleaner, more maintainable, and less error-prone. I've also pointed out a minor style issue in a test file.

Overall, this is a good set of improvements to the codebase's quality and consistency.

@mmathieum mmathieum marked this pull request as ready for review January 15, 2026 17:11
@mmathieum
Copy link
Member Author

/gemini review

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 a number of cleanups and refactorings. Notably, it adds support for MTrip objects, refactors SQL ID escaping, and improves sorting logic for service dates. The code quality is improved by using try-with-resources in several places.

My review includes a few suggestions for further improvement:

  • In DBUtils.kt, I've pointed out an opportunity to improve query string building for both efficiency (using StringBuilder) and readability (avoiding semicolons for multiple statements on one line).
  • In MGenerator.java, I've suggested renaming a couple of constants to better reflect their values, which will improve maintainability.
  • I also found a piece of commented-out code in MGenerator.java that could be removed.

Overall, these are good changes that improve the codebase.

@mmathieum mmathieum requested a review from Copilot January 16, 2026 13:37
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR performs cleanup and refactoring in preparation for vehicle-related changes, focusing on improving code organization and introducing new data structures.

Changes:

  • Renamed escaping functions from escape() to escapeId() and quotesEscape() to quotesEscapeId() for ID-specific SQL escaping
  • Added new MTrip data class and integrated it into the data processing pipeline
  • Refactored sorting and file export logic for service dates and schedules with new feature flags

Reviewed changes

Copilot reviewed 16 out of 16 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/test/java/org/mtransit/parser/mt/data/MServiceDateTest.kt Updated test to use explicit comparator instead of default sorting
src/main/java/org/mtransit/parser/mt/data/MTripIds.kt Renamed method call from quotesEscape() to quotesEscapeId()
src/main/java/org/mtransit/parser/mt/data/MTripId.kt Renamed method call from quotesEscape() to quotesEscapeId()
src/main/java/org/mtransit/parser/mt/data/MTrip.kt New data class representing transit trips with serialization support
src/main/java/org/mtransit/parser/mt/data/MSpec.kt Added trips field to the spec data class
src/main/java/org/mtransit/parser/mt/data/MServiceIds.kt Renamed method call from quotesEscape() to quotesEscapeId()
src/main/java/org/mtransit/parser/mt/data/MServiceId.kt Renamed method call from quotesEscape() to quotesEscapeId()
src/main/java/org/mtransit/parser/mt/data/MServiceDate.kt Removed Comparable interface, added comparators and flattened export logic
src/main/java/org/mtransit/parser/mt/data/MSchedule.kt Refactored sorting logic with feature flag support and improved formatting
src/main/java/org/mtransit/parser/mt/MGenerator.java Added trip dumping logic and refactored service date export
src/main/java/org/mtransit/parser/mt/MDataChangedManager.kt Updated to use renamed escapeId() method
src/main/java/org/mtransit/parser/mt/GenerateMObjectsTask.java Integrated MTrip collection and processing
src/main/java/org/mtransit/parser/gtfs/data/GCalendarDate.kt Updated to use renamed escapeId() method
src/main/java/org/mtransit/parser/gtfs/data/GCalendar.kt Updated to use renamed escapeId() method
src/main/java/org/mtransit/parser/db/SQLUtils.kt Added new escapeId() and quotesEscapeId() functions for ID-specific escaping
src/main/java/org/mtransit/parser/db/DBUtils.kt Refactored query building logic and fixed index initialization

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@mmathieum mmathieum merged commit f33814b into master Jan 16, 2026
4 checks passed
@mmathieum mmathieum deleted the mm/pre_vehicle_cleanup branch January 16, 2026 17:58
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