-
Notifications
You must be signed in to change notification settings - Fork 536
Fix 0814 2 #1345
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix 0814 2 #1345
Changes from all commits
5b83045
7619290
44e92de
61b90c0
c8f13a6
420eeae
6f6c07d
ba9b2b0
562734d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -401,7 +401,7 @@ async fn list_system_events_for_calendars( | |
| let filter = EventFilter { | ||
| calendar_tracking_id: calendar_tracking_id.clone(), | ||
| from: now, | ||
| to: now + chrono::Duration::days(28), | ||
| to: now + chrono::Duration::days(100), | ||
| }; | ||
|
|
||
| // Add small delay between API calls to avoid overwhelming EventKit | ||
|
|
@@ -480,11 +480,11 @@ async fn list_db_events( | |
| .list_events(Some(ListEventFilter { | ||
| common: ListEventFilterCommon { | ||
| user_id: user_id.into(), | ||
| limit: Some(200), | ||
| limit: Some(700), | ||
| }, | ||
| specific: ListEventFilterSpecific::DateRange { | ||
| start: Utc::now(), | ||
| end: Utc::now() + chrono::Duration::days(28), | ||
| end: Utc::now() + chrono::Duration::days(100), | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 Prompt for AI agents |
||
| }, | ||
| })) | ||
| .await | ||
|
|
@@ -562,28 +562,24 @@ impl CalendarSyncState { | |
|
|
||
| impl EventSyncState { | ||
| async fn execute(self, db: &hypr_db_user::UserDatabase) { | ||
| // 1. Create new events first | ||
| for event in self.to_upsert { | ||
| if let Err(e) = db.upsert_event(event).await { | ||
| tracing::error!("upsert_event_error: {}", e); | ||
| } | ||
| } | ||
|
|
||
| // 2. Update existing events | ||
| for event in self.to_update { | ||
| if let Err(e) = db.update_event(event).await { | ||
| tracing::error!("update_event_error: {}", e); | ||
| } | ||
| } | ||
|
|
||
| // 3. Transfer sessions from old events to new events | ||
| for (session_id, new_event_id) in self.session_transfers { | ||
| if let Err(e) = db.session_set_event(session_id, Some(new_event_id)).await { | ||
| tracing::error!("session_transfer_error: {}", e); | ||
| } | ||
| } | ||
|
|
||
| // 4. Delete old events last (after sessions have been transferred) | ||
| for event in self.to_delete { | ||
| if let Err(e) = db.delete_event(&event.id).await { | ||
| tracing::error!("delete_event_error: {}", e); | ||
|
|
||
There was a problem hiding this comment.
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:
Add this near the top of the file (after imports) to support the change:
Run this to catch any other stale 28-day or newly hard-coded 100-day windows that should use the constant:
🏁 Script executed:
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:
Suggested changes (apply across the listed files):
Then import and use it in other crates:
chrono::Duration::days(SYNC_WINDOW_DAYS).plugins/apple-calendar/src/sync.rs
plugins/apple-calendar/src/sync.rs (other occurrence)
crates/calendar-apple/src/lib.rs
crates/db-user/src/init.rs
After changes, re-run the search to confirm no remaining literals:
rg -n -S $'Duration::days\(\s100\s\)'
🤖 Prompt for AI Agents