Repository navigation
Fix calendar_dates outside of calendars coverage issue. - #83
Conversation
Some transit agencies #TTC publishes special days service in `calendar_dates` outside of the `calendars` coverage. The issue was that the app data contains a random day schedule in the future w/o the other days in the middle which will show as "no service" instead of displaying previous week(s) schedule.
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughThe parser now honors ChangesGTFS date handling
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant GReader
participant GSpec
participant GCalendarDate
GReader->>GSpec: parse calendar.txt
GSpec-->>GReader: return calendar coverage bounds
GReader->>GCalendarDate: check calendar-date coverage
GCalendarDate-->>GReader: accept or ignore record
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Pull request overview
Adjusts GTFS ingestion to avoid “no service” gaps caused by calendar_dates.txt entries that fall outside the overall calendar.txt coverage window (e.g., a lone future special-service date without intermediate schedules).
Changes:
- Read
calendar.txtbeforecalendar_dates.txtand compute the overall calendars min/max coverage dates. - Ignore
calendar_dates.txtrows that are outside that computedcalendar.txtcoverage window (while still accepting calendar-dates-only feeds). - Refactor “today” handling in
DefaultAgencyToolsto centralize date selection ingetTodayDateInt().
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/main/java/org/mtransit/parser/gtfs/GReader.java | Reorders parsing and filters calendar_dates against calendar coverage bounds to prevent sparse future dates from creating “no service” gaps. |
| src/main/java/org/mtransit/parser/gtfs/data/GSpecExt.kt | Adds Kotlin extensions to compute calendar coverage bounds and a helper to check whether a calendar date falls within them. |
| src/main/java/org/mtransit/parser/DefaultAgencyTools.java | Centralizes the “today” value via getTodayDateInt() and simplifies how the useful period’s “today” is set. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
left a comment
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/main/java/org/mtransit/parser/gtfs/data/GSpecExt.kt (1)
14-15: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winRename the local upper-bound variable.
calendarsMaxStartDateactually contains the maximum end date. Rename it tocalendarsMaxEndDateso theisBetweenupper bound remains unambiguous and future edits do not reintroduce the start/end mix-up.🤖 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/parser/gtfs/data/GSpecExt.kt` around lines 14 - 15, In the surrounding calendar date-range logic, rename the local variable calendarsMaxStartDate to calendarsMaxEndDate to match the value returned by calendarsMaxEndDate(), and update its use as the upper bound in gCalendarDate.isBetween without changing behavior.
🤖 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/parser/gtfs/data/GSpecExt.kt`:
- Around line 14-15: In the surrounding calendar date-range logic, rename the
local variable calendarsMaxStartDate to calendarsMaxEndDate to match the value
returned by calendarsMaxEndDate(), and update its use as the upper bound in
gCalendarDate.isBetween without changing behavior.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 798a8a1c-13ac-482a-8a07-cc65389e823b
📒 Files selected for processing (2)
src/main/java/org/mtransit/parser/gtfs/GReader.javasrc/main/java/org/mtransit/parser/gtfs/data/GSpecExt.kt
🚧 Files skipped from review as they are similar to previous changes (1)
- src/main/java/org/mtransit/parser/gtfs/GReader.java
left a comment
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (1)
src/main/java/org/mtransit/parser/gtfs/data/GSpecExt.kt:15
- Local variable name
calendarsMaxStartDateis misleading here: it actually holds the max end date (fromcalendarsMaxEndDate()), which makes the coverage logic harder to read and easy to misinterpret during future changes.
val calendarsMinStartDate = calendarsMinStartDate() ?: return null // no calendars (only calendar dates inside GTFS)
val calendarsMaxStartDate = calendarsMaxEndDate() ?: return null // no calendars (only calendar dates inside GTFS)
return gCalendarDate.isBetween(calendarsMinStartDate, calendarsMaxStartDate)
Some transit agencies #TTC publishes special days service in
calendar_datesoutside of thecalendarscoverage. The issue was that the app data contains a random day schedule in the future w/o the other days in the middle which will show as "no service" instead of displaying previous week(s) schedule.