Skip to content

Fix calendar_dates outside of calendars coverage issue. - #83

Merged
mmathieum merged 4 commits into
masterfrom
mm/fix_calendar_dates_outside_calendars_coverage
Jul 28, 2026
Merged

mmathieum merged 4 commits into
masterfrom
mm/fix_calendar_dates_outside_calendars_coverage

Conversation

@mmathieum

Copy link
Copy Markdown
Member

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.

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.
@coderabbitai

coderabbitai Bot commented Jul 28, 2026 •

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It 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 reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

The parser now honors OVERRIDE_DATE when deriving today’s date and filters calendar_dates.txt entries against the date coverage defined by parsed calendars before applying existing year and agency checks.

Changes

GTFS date handling

Layer / File(s) Summary
Agency date override propagation
src/main/java/org/mtransit/parser/DefaultAgencyTools.java
getTodayDateInt() returns the configured override date directly, and useful service-period extraction uses that value.
Calendar coverage filtering
src/main/java/org/mtransit/parser/gtfs/data/GSpecExt.kt, src/main/java/org/mtransit/parser/gtfs/GReader.java
Calendar bounds are derived from allCalendars; calendar.txt is parsed before calendar_dates.txt, whose records are filtered against those bounds and existing year limits.

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
Loading
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main fix for calendar_dates entries outside calendars coverage.
Description check ✅ Passed The description matches the changes by describing special-day calendar_dates outside calendar coverage causing no-service gaps.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch mm/fix_calendar_dates_outside_calendars_coverage

Comment @coderabbitai help to get the list of available commands.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.txt before calendar_dates.txt and compute the overall calendars min/max coverage dates.
  • Ignore calendar_dates.txt rows that are outside that computed calendar.txt coverage window (while still accepting calendar-dates-only feeds).
  • Refactor “today” handling in DefaultAgencyTools to centralize date selection in getTodayDateInt().

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.

ghost left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
src/main/java/org/mtransit/parser/gtfs/data/GSpecExt.kt (1)

14-15: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Rename the local upper-bound variable.

calendarsMaxStartDate actually contains the maximum end date. Rename it to calendarsMaxEndDate so the isBetween upper 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

📥 Commits

Reviewing files that changed from the base of the PR and between ff38187 and eee0cbc.

📒 Files selected for processing (2)
  • src/main/java/org/mtransit/parser/gtfs/GReader.java
  • src/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

ghost left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 calendarsMaxStartDate is misleading here: it actually holds the max end date (from calendarsMaxEndDate()), 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)

@mmathieum
mmathieum merged commit 1fc5217 into master Jul 28, 2026
@mmathieum
mmathieum deleted the mm/fix_calendar_dates_outside_calendars_coverage branch July 28, 2026 15:34
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