Skip to content

Fix 0814 2#1345

Merged
duckduckhero merged 9 commits intomainfrom
fix-0814-2
Aug 14, 2025
Merged

Fix 0814 2#1345
duckduckhero merged 9 commits intomainfrom
fix-0814-2

Conversation

@duckduckhero
Copy link
Contributor

@duckduckhero duckduckhero commented Aug 14, 2025

  • calendar to future 100 days

Summary by cubic

Expanded calendar event syncing and listing to include events up to 100 days into the future instead of 28 days.

  • Code Cleanup
  • Removed outdated comments from the event sync logic for clarity.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Aug 14, 2025

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

📝 Walkthrough

Walkthrough

Extended event retrieval windows from 28 to 100 days for both system and database queries in the Apple Calendar sync module. Removed four inline comments; execution order and behavior remain unchanged.

Changes

Cohort / File(s) Summary of Changes
Sync window expansion
plugins/apple-calendar/src/sync.rs
- list_system_events_for_calendars: end bound changed from now + 28 days to now + 100 days.
- list_db_events: end bound changed from now + 28 days to now + 100 days and result limit increased from 200 to 700.
- Removed four inline comments about processing order; actual execution order (upsert → update → session_transfer → delete) unchanged.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

  • Event timing issue #1198 — Modifies the same plugins/apple-calendar/src/sync.rs functions and adjusts event fetch/query ranges.

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.


📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these settings in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between ba9b2b0 and 562734d.

📒 Files selected for processing (1)
  • plugins/apple-calendar/src/sync.rs (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • plugins/apple-calendar/src/sync.rs
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: ci (macos, macos-latest)
  • GitHub Check: ci (windows, windows-latest)
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix-0814-2

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

‼️ IMPORTANT
Auto-reply has been disabled for this repository in the CodeRabbit settings. The CodeRabbit bot will not respond to your replies unless it is explicitly tagged.

  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

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

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

cubic analysis

1 issue found across 1 file • Review in cubic

React with 👍 or 👎 to teach cubic. You can also tag @cubic-dev-ai to give feedback, ask questions, or re-run the review.

specific: ListEventFilterSpecific::DateRange {
start: Utc::now(),
end: Utc::now() + chrono::Duration::days(28),
end: Utc::now() + chrono::Duration::days(100),
Copy link

Choose a reason for hiding this comment

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

The date-range has been extended from 28 days to 100 days while the limit field on the preceding ListEventFilterCommon is still hard-coded to 200. If more than 200 events exist in a 100-day window, newer events will be silently omitted, resulting in incomplete synchronisation data. Increase the limit or calculate it dynamically to match the wider range.

Prompt for AI agents
Address the following comment on plugins/apple-calendar/src/sync.rs at line 487:

<comment>The date-range has been extended from 28 days to 100 days while the `limit` field on the preceding `ListEventFilterCommon` is still hard-coded to 200. If more than 200 events exist in a 100-day window, newer events will be silently omitted, resulting in incomplete synchronisation data. Increase the limit or calculate it dynamically to match the wider range.</comment>

<file context>
@@ -484,7 +484,7 @@ async fn list_db_events(
             },
             specific: ListEventFilterSpecific::DateRange {
                 start: Utc::now(),
-                end: Utc::now() + chrono::Duration::days(28),
+                end: Utc::now() + chrono::Duration::days(100),
             },
         }))
</file context>

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🔭 Outside diff range comments (3)
plugins/apple-calendar/src/sync.rs (3)

481-488: 200-event limit will miss data for a 100-day window, causing duplicate upserts and missed updates

With a larger time range, fetching only 200 events risks not seeing existing DB events during reconciliation, which can lead to duplicate inserts or missed updates. Remove the limit (or significantly raise it) and reuse the same window constant as the system fetch.

Apply this diff:

             common: ListEventFilterCommon {
                 user_id: user_id.into(),
-                limit: Some(200),
+                // Fetch the full 100-day window to avoid missing events and creating duplicates
+                limit: None,
             },
             specific: ListEventFilterSpecific::DateRange {
                 start: Utc::now(),
-                end: Utc::now() + chrono::Duration::days(100),
+                end: Utc::now() + chrono::Duration::days(SYNC_WINDOW_DAYS),
             },

255-262: Avoid O(N^2) scans; use the handled_system_event_ids HashSet you already maintain

This path scans state.to_update for every system event. With 100 days, this scales poorly. Use handled_system_event_ids for O(1) membership checks (you already populate it when updating).

Apply this diff:

-                // Skip if this event was already handled as an update
-                let already_handled = state
-                    .to_update
-                    .iter()
-                    .any(|e| e.tracking_id == composite_tracking_id);
-                if already_handled {
-                    continue;
-                }
+                // Skip if this event was already handled as an update
+                if handled_system_event_ids.contains(&composite_tracking_id) {
+                    continue;
+                }

428-437: PII-heavy and high-volume logging; downgrade and redact for 100-day scale

Logging titles, participants, and IDs at info level for every event will be noisy and may leak PII. Use debug level and avoid dumping participant details.

Apply this diff:

-            for event in &events {
-                tracing::info!(
-                    "System event: '{}' | participants: {:?} | is_recurring: {} | start_date: {} | tracking_id: {}",
-                    event.name,
-                    event.participants,
-                    event.is_recurring,
-                    event.start_date,
-                    event.id,
-                );
-            }
+            for event in &events {
+                tracing::debug!(
+                    "System event fetched | participants={} | is_recurring={} | start_date={}",
+                    event.participants.len(),
+                    event.is_recurring,
+                    event.start_date,
+                );
+            }
🧹 Nitpick comments (1)
plugins/apple-calendar/src/sync.rs (1)

506-513: N+1 DB lookups for sessions will not scale with a 100-day window

Fetching sessions one-by-one per event will amplify latency and DB load. Prefer a batched API (e.g., list sessions by event IDs) or a join in list_events_with_sessions to eliminate the N+1 pattern.

I can sketch an API change for hypr_db_user to fetch sessions by a set of event IDs if that’s feasible on your side.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these settings in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 8bc7a5e and ba9b2b0.

📒 Files selected for processing (1)
  • plugins/apple-calendar/src/sync.rs (2 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{js,ts,tsx,rs}

⚙️ CodeRabbit Configuration File

**/*.{js,ts,tsx,rs}: 1. No error handling.
2. No unused imports, variables, or functions.
3. For comments, keep it minimal. It should be about "Why", not "What".

Files:

  • plugins/apple-calendar/src/sync.rs
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: cubic · AI code reviewer
  • GitHub Check: ci (macos, macos-latest)
  • GitHub Check: ci (windows, windows-latest)

Comment on lines 401 to 405
let filter = EventFilter {
calendar_tracking_id: calendar_tracking_id.clone(),
from: now,
to: now + chrono::Duration::days(28),
to: now + chrono::Duration::days(100),
};
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

Consolidate the 100-day window into a single constant to keep system and DB queries in lockstep

Hard-coding 100 in multiple places is brittle. Define one constant and reuse it here and in the DB filter to prevent drift.

Apply this diff within the current block:

-                to: now + chrono::Duration::days(100),
+                to: now + chrono::Duration::days(SYNC_WINDOW_DAYS),

Add this near the top of the file (after imports) to support the change:

const SYNC_WINDOW_DAYS: i64 = 100;

Run this to catch any other stale 28-day or newly hard-coded 100-day windows that should use the constant:


🏁 Script executed:

#!/bin/bash
# Find any lingering 28-day or hard-coded 100-day duration usages
rg -n -S $'Duration::days\\(\\s*28\\s*\\)|Duration::days\\(\\s*100\\s*\\)'

Length of output: 651


Consolidate hard-coded 100-day window into a single constant (fix required)

rg found multiple hard-coded uses of Duration::days(100). Replace them with a single constant to avoid drift between system and DB queries.

Files/locations to update:

  • plugins/apple-calendar/src/sync.rs — lines ~404 and ~487
  • crates/calendar-apple/src/lib.rs — lines ~315–316
  • crates/db-user/src/init.rs — lines ~738–739

Suggested changes (apply across the listed files):

  1. Prefer a single, shared constant if your workspace has a common/shared crate. Example (in that crate):
pub const SYNC_WINDOW_DAYS: i64 = 100;

Then import and use it in other crates: chrono::Duration::days(SYNC_WINDOW_DAYS).

  1. If a shared crate isn't available, add a per-crate/file constant near the imports:
const SYNC_WINDOW_DAYS: i64 = 100;
  1. Replace literals. Example diffs:

plugins/apple-calendar/src/sync.rs

-                to: now + chrono::Duration::days(100),
+                to: now + chrono::Duration::days(SYNC_WINDOW_DAYS),

plugins/apple-calendar/src/sync.rs (other occurrence)

-                end: Utc::now() + chrono::Duration::days(100),
+                end: Utc::now() + chrono::Duration::days(SYNC_WINDOW_DAYS),

crates/calendar-apple/src/lib.rs

-            from: chrono::Utc::now() - chrono::Duration::days(100),
-            to: chrono::Utc::now() + chrono::Duration::days(100),
+            from: chrono::Utc::now() - chrono::Duration::days(SYNC_WINDOW_DAYS),
+            to: chrono::Utc::now() + chrono::Duration::days(SYNC_WINDOW_DAYS),

crates/db-user/src/init.rs

-            created_at: now - chrono::Duration::days(100),
-            visited_at: now - chrono::Duration::days(100),
+            created_at: now - chrono::Duration::days(SYNC_WINDOW_DAYS),
+            visited_at: now - chrono::Duration::days(SYNC_WINDOW_DAYS),

After changes, re-run the search to confirm no remaining literals:
rg -n -S $'Duration::days\(\s100\s\)'

🤖 Prompt for AI Agents
In plugins/apple-calendar/src/sync.rs around lines 401–405 and ~487,
crates/calendar-apple/src/lib.rs around lines 315–316, and
crates/db-user/src/init.rs around lines 738–739, replace the hard-coded
chrono::Duration::days(100) occurrences with a single named constant; preferably
add a shared constant pub const SYNC_WINDOW_DAYS: i64 = 100 in a common
workspace crate and import it where needed, using
chrono::Duration::days(SYNC_WINDOW_DAYS), or if no shared crate is available
declare const SYNC_WINDOW_DAYS: i64 = 100 near the file imports in each crate
and use that constant similarly; update the imports/usages accordingly and
re-run rg -n -S $'Duration::days\\(\\s*100\\s*\\)' to confirm no remaining
literals.

@duckduckhero duckduckhero merged commit 613dc14 into main Aug 14, 2025
6 checks passed
@ComputelessComputer ComputelessComputer deleted the fix-0814-2 branch December 14, 2025 15:22
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