Skip to content

participants based invitees #1044

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

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

plyght
Copy link
Collaborator

@plyght plyght commented Jun 30, 2025

fixes #877

Copy link

coderabbitai bot commented Jun 30, 2025

📝 Walkthrough

Walkthrough

The changes introduce participant management for calendar events across Apple, Google, and Outlook integrations. A new Participant struct is defined, and methods to fetch event participants by event ID are implemented in each calendar provider. The database schema is updated to store participants, and new synchronization functions and Tauri commands are added to manage session participants, including linking participants to human records in the database.

Changes

File(s) Change Summary
crates/calendar-apple/src/lib.rs
crates/calendar-google/src/lib.rs
crates/calendar-outlook/src/lib.rs
Added async method get_event_participants to CalendarSource trait implementations for each provider to fetch event participants.
crates/calendar-interface/src/lib.rs Added get_event_participants async method to CalendarSource trait.
crates/db-user/src/events_types.rs Introduced public Participant struct with name and optional email.
crates/db-user/src/events_migration_1.sql Added participants TEXT column (default '[]', NOT NULL) to events table.
crates/db-user/src/events_ops.rs Refactored event deserialization into new helper method deserialize_event_from_row.
crates/db-user/src/humans_ops.rs Added async method get_human_by_email to fetch Human by email.
crates/db-user/src/lib.rs Added new migration (events_migration_1.sql) to MIGRATIONS array, increasing its size by one.
crates/db-user/src/sessions_ops.rs Refactored session ID handling in visit_session; added comment about separate participant management.
crates/calendar-outlook/Cargo.toml Added serde_json as a workspace dependency.
plugins/apple-calendar/src/commands.rs Added async Tauri command sync_session_participants.
plugins/apple-calendar/src/ext.rs Added sync_session_participants method to AppleCalendarPluginExt trait and its implementation.
plugins/apple-calendar/src/sync.rs Added participant sync: public async functions for fetching event participants and syncing session participants with the database.

Sequence Diagram(s)

sequenceDiagram
    participant UI
    participant TauriCmd
    participant PluginExt
    participant SyncModule
    participant CalendarAPI
    participant DB

    UI->>TauriCmd: sync_session_participants(session_id)
    TauriCmd->>PluginExt: sync_session_participants(session_id)
    PluginExt->>SyncModule: sync_session_participants(db, session_id)
    SyncModule->>DB: fetch linked event for session_id
    SyncModule->>CalendarAPI: get_event_participants(event_tracking_id)
    CalendarAPI-->>SyncModule: Vec<Participant>
    loop for each Participant
        SyncModule->>DB: get_human_by_email(participant.email)
        alt Human exists
            SyncModule->>DB: update Human record
        else Human missing
            SyncModule->>DB: create new Human record
        end
        SyncModule->>DB: associate Human as session participant
    end
    SyncModule-->>PluginExt: Result
    PluginExt-->>TauriCmd: Result
    TauriCmd-->>UI: Result
Loading
sequenceDiagram
    participant App
    participant CalendarSource
    participant CalendarProvider

    App->>CalendarSource: get_event_participants(event_tracking_id)
    CalendarSource->>CalendarProvider: fetch event by ID
    CalendarProvider-->>CalendarSource: event (with attendees)
    CalendarSource-->>App: Vec<Participant>
Loading

Assessment against linked issues

Objective Addressed Explanation
Add participants to event notes based on invitees (#877)

Assessment against linked issues: Out-of-scope changes

No out-of-scope changes detected.

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 Clippy (1.86.0)
Updating git repository `https://github.com/RustAudio/cpal`

error: failed to load source for dependency cpal

Caused by:
Unable to update https://github.com/RustAudio/cpal?rev=51c3b43#51c3b43c

Caused by:
failed to create directory /usr/local/git/db/cpal-476cd1dd23dbc279

Caused by:
Permission denied (os error 13)


📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 0a56866 and 7be289f.

📒 Files selected for processing (3)
  • crates/calendar-google/src/lib.rs (1 hunks)
  • crates/calendar-outlook/src/lib.rs (2 hunks)
  • plugins/apple-calendar/src/sync.rs (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • crates/calendar-google/src/lib.rs
  • plugins/apple-calendar/src/sync.rs
🧰 Additional context used
📓 Path-based instructions (1)
`**/*.{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".

**/*.{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".

⚙️ Source: CodeRabbit Configuration File

List of files the instruction was applied to:

  • crates/calendar-outlook/src/lib.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: ci (macos, macos-latest)
  • GitHub Check: ci (windows, windows-latest)
  • GitHub Check: ci
🔇 Additional comments (2)
crates/calendar-outlook/src/lib.rs (2)

3-3: LGTM: Import addition is correct.

The Participant import is properly added to support the new method implementation.


25-125: LGTM: Implementation addresses all previous concerns.

The get_event_participants method implementation has been significantly improved and now properly addresses all the issues raised in the previous review:

  1. Empty email handling: Lines 99-103 correctly set email to None for empty strings instead of Some(empty_string)
  2. Data validation: Lines 76-122 include proper validation of the JSON response structure before parsing
  3. Consistent error handling: Lines 42-49 return empty vectors for "not found" errors, aligning with Apple and Google implementations

The implementation is now robust, well-structured, and handles edge cases appropriately.

✨ Finishing Touches
  • 📝 Generate Docstrings

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. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • 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 src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

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

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

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.

Documentation and Community

  • 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.

@plyght plyght changed the title Plyght/participants based invitees participants based invitees Jun 30, 2025
Copy link

@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: 3

🧹 Nitpick comments (3)
crates/db-user/src/events_ops.rs (1)

144-147: Consider if the helper method adds sufficient value.

The deserialize_event_from_row method is currently just a thin wrapper around libsql::de::from_row. While it centralizes the logic, it doesn't add significant functionality. Consider whether this abstraction is necessary unless you plan to add additional processing logic in the future.

crates/calendar-google/src/lib.rs (1)

114-150: Consider performance optimization for calendar search.

The current implementation searches through all calendars sequentially, which could be inefficient if a user has many calendars. However, this approach aligns with the implementations in the Apple and Outlook calendar crates.

If performance becomes an issue in production, consider implementing a caching mechanism or allowing the caller to provide a hint about which calendar contains the event.

plugins/apple-calendar/src/sync.rs (1)

370-377: Remove redundant warning log.

The error is both logged as a warning and returned, which is redundant since the caller will likely log or handle the error.

-            Err(e) => {
-                tracing::warn!(
-                    "Failed to get calendar event participants for tracking_id {}: {}",
-                    event.tracking_id,
-                    e
-                );
-                return Err(e);
-            }
+            Err(e) => {
+                return Err(e);
+            }
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 3b5823a and 0a56866.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (14)
  • crates/calendar-apple/src/lib.rs (2 hunks)
  • crates/calendar-google/src/lib.rs (1 hunks)
  • crates/calendar-interface/src/lib.rs (1 hunks)
  • crates/calendar-outlook/Cargo.toml (1 hunks)
  • crates/calendar-outlook/src/lib.rs (2 hunks)
  • crates/db-user/src/events_migration_1.sql (1 hunks)
  • crates/db-user/src/events_ops.rs (3 hunks)
  • crates/db-user/src/events_types.rs (1 hunks)
  • crates/db-user/src/humans_ops.rs (1 hunks)
  • crates/db-user/src/lib.rs (2 hunks)
  • crates/db-user/src/sessions_ops.rs (1 hunks)
  • plugins/apple-calendar/src/commands.rs (1 hunks)
  • plugins/apple-calendar/src/ext.rs (2 hunks)
  • plugins/apple-calendar/src/sync.rs (2 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
`**/*.{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".

**/*.{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".

⚙️ Source: CodeRabbit Configuration File

List of files the instruction was applied to:

  • crates/calendar-interface/src/lib.rs
  • plugins/apple-calendar/src/commands.rs
  • crates/db-user/src/lib.rs
  • crates/db-user/src/humans_ops.rs
  • crates/db-user/src/events_types.rs
  • crates/db-user/src/events_ops.rs
  • crates/calendar-google/src/lib.rs
  • crates/db-user/src/sessions_ops.rs
  • plugins/apple-calendar/src/ext.rs
  • crates/calendar-apple/src/lib.rs
  • crates/calendar-outlook/src/lib.rs
  • plugins/apple-calendar/src/sync.rs
🧬 Code Graph Analysis (2)
crates/calendar-google/src/lib.rs (3)
crates/calendar-outlook/src/lib.rs (1)
  • get_event_participants (25-70)
crates/calendar-interface/src/lib.rs (1)
  • get_event_participants (10-13)
crates/calendar-apple/src/lib.rs (1)
  • get_event_participants (302-320)
crates/calendar-outlook/src/lib.rs (3)
crates/calendar-google/src/lib.rs (3)
  • get_event_participants (114-150)
  • event (88-95)
  • event (131-138)
crates/calendar-interface/src/lib.rs (1)
  • get_event_participants (10-13)
crates/calendar-apple/src/lib.rs (1)
  • get_event_participants (302-320)
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: ci (macos, macos-latest)
  • GitHub Check: ci
  • GitHub Check: ci (windows, windows-latest)
🔇 Additional comments (14)
crates/calendar-outlook/Cargo.toml (1)

10-10: LGTM! Dependency addition is appropriate.

The serde_json workspace dependency is correctly added to support JSON parsing for the new participant retrieval functionality.

crates/db-user/src/events_migration_1.sql (1)

1-4: LGTM! Migration is correctly structured.

The migration properly adds a participants column with appropriate type, default value, and constraints to support the new participant functionality.

crates/db-user/src/events_types.rs (1)

5-10: LGTM! Well-designed participant structure.

The Participant struct is appropriately designed with mandatory name and optional email fields, following established patterns in the codebase.

crates/db-user/src/humans_ops.rs (1)

16-27: LGTM! Method follows established patterns correctly.

The get_human_by_email method is well-implemented, following the same secure pattern as the existing get_human method with proper parameterized queries and consistent error handling.

crates/db-user/src/lib.rs (2)

132-132: LGTM! Migration array correctly updated.

The array size is properly incremented to reflect the addition of the new migration file.


151-151: LGTM! New migration correctly appended.

The new migration file is properly added at the end of the array, following the append-only pattern for database migrations.

crates/calendar-interface/src/lib.rs (1)

10-13: LGTM! Trait method addition follows established patterns.

The new get_event_participants method signature is consistent with other async trait methods and properly defines the interface for participant retrieval across different calendar providers.

crates/db-user/src/sessions_ops.rs (1)

95-106: LGTM! Good refactoring that eliminates redundant conversions.

Extracting the session ID into a variable improves readability and prevents duplicate conversions. The comment provides helpful context about the separation of participant management concerns.

plugins/apple-calendar/src/commands.rs (1)

61-70: LGTM! Command implementation follows established patterns.

The new sync_session_participants command is consistent with other commands in the file, using the same annotations and error handling approach.

crates/calendar-outlook/src/lib.rs (1)

3-3: Verify the Participant import is used correctly.

The import looks correct and is used in the implementation below.

plugins/apple-calendar/src/ext.rs (1)

15-18: LGTM!

The new sync_session_participants method follows the established pattern of other sync methods in this trait. The implementation properly handles database state locking and error propagation.

Also applies to: 145-154

crates/calendar-apple/src/lib.rs (2)

135-179: Consider the implications of the ±365 day search range.

The method searches for events within a hardcoded ±365 day range. This could miss events that fall outside this window.

Is this date range limitation intentional? If events can exist beyond this range, consider:

  1. Making the range configurable
  2. Using a wider range
  3. Documenting this limitation
-                    (chrono::Utc::now() - chrono::Duration::days(365)).timestamp() as f64,
+                    // Search within a 2-year window to ensure we don't miss events
+                    (chrono::Utc::now() - chrono::Duration::days(730)).timestamp() as f64,

302-320: Implementation follows established patterns.

The get_event_participants method properly checks calendar access and handles the case when an event is not found by returning an empty vector.

plugins/apple-calendar/src/sync.rs (1)

311-324: Well-structured participant synchronization implementation.

The implementation properly handles:

  • Creating new humans or updating existing ones based on email
  • Database error propagation
  • Proper abstraction with the helper function

Also applies to: 325-382

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.

Add participants to event notes based on invitees
1 participant