Skip to content

Include past events in calendar feeds#16

Merged
DisabledAbel merged 3 commits into
mainfrom
include-past-events-8696227538873545827
Jun 12, 2026
Merged

Include past events in calendar feeds#16
DisabledAbel merged 3 commits into
mainfrom
include-past-events-8696227538873545827

Conversation

@DisabledAbel

@DisabledAbel DisabledAbel commented Jun 12, 2026

Copy link
Copy Markdown
Owner

This change modifies the backend and frontend logic to stop filtering out past events. TV show and Sports team calendars will now include historical events alongside future ones.

Key changes:

  • Removed date-based filtering in lib/tvEpisodes.js and lib/sports.js.
  • Renamed getUpcomingEpisodes and getUpcomingEvents to getEpisodes and getEvents.
  • Updated API handlers and ICS generators to use the new "all-time" logic.
  • Updated the frontend UI to remove "Upcoming" labels and update helpful hints.
  • Updated tests to ensure past events are correctly returned and displayed.

PR created automatically by Jules for task 8696227538873545827 started by @DisabledAbel

Summary by CodeRabbit

  • New Features
    • Expanded episode search to include all available episodes, not just upcoming ones.
    • Expanded event search to include all available events, not just upcoming ones.
    • Updated result messages and calendar descriptions to reflect the broader scope of searchable content.

Removed time-based filtering that previously excluded past events from the calendar feeds and UI. Core library functions were renamed from "Upcoming" variants to more general names (e.g., getEpisodes, getEvents) to reflect the inclusion of both past and future data. Updated the frontend UI and ICS metadata to remove "Upcoming" labeling.
@google-labs-jules

Copy link
Copy Markdown
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@vercel

vercel Bot commented Jun 12, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
make-ics Ready Ready Preview, Comment Jun 12, 2026 8:53pm

@coderabbitai

coderabbitai Bot commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@DisabledAbel, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 31 minutes and 36 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more credits in the billing tab to continue.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: b2443246-b5af-4376-ab8f-7982e7607f58

📥 Commits

Reviewing files that changed from the base of the PR and between f3e7d2b and 3f36aea.

📒 Files selected for processing (5)
  • api/episodes.js
  • api/sports-events.js
  • lib/sports.js
  • lib/tvEpisodes.js
  • public/app.js
📝 Walkthrough

Walkthrough

The PR refactors the episode and sports event libraries from upcoming-only exports to all-time exports. getUpcomingEpisodes becomes getEpisodes with normalized episode sorting; getUpcomingEvents becomes getEvents with optional now parameter and removed 3-hour window filter. APIs, UI labels, and test coverage are updated throughout.

Changes

Episode and Sports Event Scope Expansion

Layer / File(s) Summary
Core Library Refactors
lib/tvEpisodes.js, lib/sports.js
lib/tvEpisodes.js renames getUpcomingEpisodes to getEpisodes, introduces normalizeEpisodes for sorting episodes by air timestamp, and returns all normalized episodes instead of filtering for future-only; lib/sports.js renames getUpcomingEvents to getEvents with optional now parameter, removes the 3-hour event window filter, and returns all sorted deduplicated events. Both update ICS PRODID identifiers and remove "upcoming" from description wording.
API Endpoint Updates
api/episodes.js, api/sports-events.js
Both endpoints update their imports and handler calls to use the renamed functions; api/episodes.js also updates the error message fallback from "upcoming episodes" to "Unable to fetch episodes."
User-Facing Label Updates
public/app.js
Removes "upcoming" language from the sports category hint and event count messages, displaying "event(s) found" and "No events found" instead of prior "upcoming event(s) found" wording.
TV Episodes Test Coverage
test/tvEpisodes.test.js
Updates all test cases to call getEpisodes, adds coverage for 3-episode results including past episodes ("Already Aired"), validates default free IMDb enrichment, adds tests for IMDb error recovery (HTTP 500 and network failures with warning recording), and validates rejection of missing/blank show names.
Sports Events Test Coverage
test/sports.test.js
Updates all test cases to call getEvents, adds test asserting past events are included when mocked to a later date, updates cache utilization and scraped data merge tests, refines ICS generation test, and improves fetch mock specificity to avoid unexpected network calls.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • DisabledAbel/MakeICS#11: Both refactor lib/sports.js event filtering logic from upcoming-only to full merged event sets with optional now parameter.
  • DisabledAbel/MakeICS#4: Directly related refactor of the /api/episodes + lib/tvEpisodes.js flow replacing getUpcomingEpisodes with getEpisodes.
  • DisabledAbel/MakeICS#9: Related update to the sports pipeline that introduced initial getUpcomingEvents logic now being refactored to getEvents.

Suggested labels

codex


🐰 A rabbit hops through the code with glee,
Events and episodes now wild and free,
No more "upcoming" to limit the view,
All shows and matches shine bright and true!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Include past events in calendar feeds' directly and clearly summarizes the main objective of the pull request: removing date-based filtering to include historical events in TV show and sports team calendars.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch include-past-events-8696227538873545827

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
lib/tvEpisodes.js (1)

334-361: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Skip unscheduled episodes before ICS serialization to prevent feed-wide 500s.

Line 361 now returns all episodes. If any episode lacks both airstamp and airdate, the ICS path later creates an invalid Date, and toISOString() throws, failing the whole calendar response.

Suggested fix
 export function toIcs(result, { timezone = 'UTC' } = {}) {
@@
   for (const episode of result.episodes) {
-    const startDate = new Date(episode.airstamp || `${episode.airdate}T${episode.airtime || '00:00'}:00Z`);
+    const rawStart = episode.airstamp || (episode.airdate ? `${episode.airdate}T${episode.airtime || '00:00'}:00Z` : null);
+    if (!rawStart) {
+      continue;
+    }
+    const startDate = new Date(rawStart);
+    if (Number.isNaN(startDate.getTime())) {
+      continue;
+    }
     const start = formatIcsDateTime(startDate);
🤖 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 `@lib/tvEpisodes.js` around lines 334 - 361, Return currently includes episodes
that may lack both airstamp and airdate, causing invalid Date and toISOString()
to throw during ICS serialization; before returning (around the
allEpisodes/normalizeEpisodes usage) filter out any episode objects where both
airstamp and airdate are falsy. Update the code that constructs allEpisodes (or
immediately before assigning episodes:) to use the output of
normalizeEpisodes(episodes, show).filter(e => e.airstamp || e.airdate) so only
scheduled episodes are returned to the ICS path and prevent feed-wide 500s.
🤖 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.

Outside diff comments:
In `@lib/tvEpisodes.js`:
- Around line 334-361: Return currently includes episodes that may lack both
airstamp and airdate, causing invalid Date and toISOString() to throw during ICS
serialization; before returning (around the allEpisodes/normalizeEpisodes usage)
filter out any episode objects where both airstamp and airdate are falsy. Update
the code that constructs allEpisodes (or immediately before assigning episodes:)
to use the output of normalizeEpisodes(episodes, show).filter(e => e.airstamp ||
e.airdate) so only scheduled episodes are returned to the ICS path and prevent
feed-wide 500s.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 39595366-3050-4650-88b5-65796e04ab3d

📥 Commits

Reviewing files that changed from the base of the PR and between e93b928 and f3e7d2b.

⛔ Files ignored due to path filters (1)
  • server_output.log is excluded by !**/*.log
📒 Files selected for processing (7)
  • api/episodes.js
  • api/sports-events.js
  • lib/sports.js
  • lib/tvEpisodes.js
  • public/app.js
  • test/sports.test.js
  • test/tvEpisodes.test.js

- Modified `lib/tvEpisodes.js` and `lib/sports.js` to include past events by removing time-based filters.
- Renamed `getUpcomingEpisodes` to `getEpisodes` and `getUpcomingEvents` to `getEvents`.
- Added a filter in `lib/tvEpisodes.js` to exclude episodes without scheduling info (`airstamp` or `airdate`) to prevent ICS generation errors.
- Updated frontend UI in `public/app.js` and metadata in `lib/tvEpisodes.js` and `lib/sports.js` to reflect that feeds now include all events, not just upcoming ones.
- Updated tests to verify inclusion of past events and new filtering logic.
- Modified `lib/tvEpisodes.js` and `lib/sports.js` to include historical events by removing internal time-based filters.
- Introduced an optional `since` parameter to `getEpisodes` and `getEvents` to allow clients to specify a start date for the feed.
- Updated `api/episodes.js` and `api/sports-events.js` to pass the `since` query parameter.
- Updated `public/app.js` to automatically include the current date as the `since` parameter in generated ICS URLs, ensuring that events are "cached" in the feed from the day the user subscribes.
- Added a safety check in `lib/tvEpisodes.js` to filter out episodes missing both `airstamp` and `airdate`.
- Updated frontend UI hints and metadata to reflect the new persistent event tracking behavior.
- Updated unit tests to verify the `since` filtering and inclusion of past events.
@DisabledAbel DisabledAbel merged commit 7201c98 into main Jun 12, 2026
4 checks passed
@DisabledAbel DisabledAbel deleted the include-past-events-8696227538873545827 branch June 12, 2026 20:56
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.

1 participant