Include past events in calendar feeds#16
Conversation
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.
|
👋 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 New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Warning Review limit reached
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 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 configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (5)
📝 WalkthroughWalkthroughThe PR refactors the episode and sports event libraries from upcoming-only exports to all-time exports. ChangesEpisode and Sports Event Scope Expansion
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested labels
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
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 winSkip unscheduled episodes before ICS serialization to prevent feed-wide 500s.
Line 361 now returns all episodes. If any episode lacks both
airstampandairdate, the ICS path later creates an invalidDate, andtoISOString()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
⛔ Files ignored due to path filters (1)
server_output.logis excluded by!**/*.log
📒 Files selected for processing (7)
api/episodes.jsapi/sports-events.jslib/sports.jslib/tvEpisodes.jspublic/app.jstest/sports.test.jstest/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.
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:
lib/tvEpisodes.jsandlib/sports.js.getUpcomingEpisodesandgetUpcomingEventstogetEpisodesandgetEvents.PR created automatically by Jules for task 8696227538873545827 started by @DisabledAbel
Summary by CodeRabbit