Skip to content

feat: CalendarCache - filter generic calendars from subscription batch#7

Open
tomerqodo wants to merge 2 commits intocoderabbit_full_base_feat_calendarcache_-_filter_generic_calendars_from_subscription_batch_pr7from
coderabbit_full_head_feat_calendarcache_-_filter_generic_calendars_from_subscription_batch_pr7
Open

feat: CalendarCache - filter generic calendars from subscription batch#7
tomerqodo wants to merge 2 commits intocoderabbit_full_base_feat_calendarcache_-_filter_generic_calendars_from_subscription_batch_pr7from
coderabbit_full_head_feat_calendarcache_-_filter_generic_calendars_from_subscription_batch_pr7

Conversation

@tomerqodo
Copy link

@tomerqodo tomerqodo commented Jan 29, 2026

Benchmark PR from agentic-review-benchmarks#7

Summary by CodeRabbit

  • New Features
    • Calendar subscriptions can now intelligently exclude generic calendar types (Google Calendar, Office 365 Calendar) from being subscribed, with provider-specific configurations to prevent unwanted calendar inclusions.

devin-ai-integration bot and others added 2 commits January 25, 2026 12:02
Add filtering to SelectedCalendarRepository.findNextSubscriptionBatch to
exclude generic calendars (holidays, contacts, shared, imported, resources)
based on their externalId suffixes.

Changes:
- Add GENERIC_CALENDAR_SUFFIXES constant mapping providers to their
  generic calendar suffixes in AdaptersFactory
- Add getGenericCalendarSuffixes method to AdapterFactory interface
- Update findNextSubscriptionBatch to accept and use genericCalendarSuffixes
  parameter to filter out calendars with matching externalId suffixes
- Update CalendarSubscriptionService.checkForNewSubscriptions to pass
  generic calendar suffixes from the adapter factory
- Update tests to cover the new filtering logic

Co-Authored-By: Volnei Munhoz <volnei.munhoz@gmail.com>
@coderabbitai
Copy link

coderabbitai bot commented Jan 29, 2026

📝 Walkthrough

Walkthrough

The PR introduces a feature to exclude generic calendar entries (such as Google Calendar's default calendar or Office 365's primary calendar) from subscription batching. It adds a configuration mapping generic calendar suffixes by provider, exposes this through the adapter factory, and implements filtering logic in the repository layer to exclude calendars matching those suffixes.

Changes

Cohort / File(s) Summary
Adapter Configuration
packages/features/calendar-subscription/adapters/AdaptersFactory.ts
Introduces GENERIC_CALENDAR_SUFFIXES constant mapping providers to generic calendar suffixes, extends AdapterFactory interface with getGenericCalendarSuffixes() method, and implements aggregation logic in DefaultAdapterFactory.
Service Layer
packages/features/calendar-subscription/lib/CalendarSubscriptionService.ts, packages/features/calendar-subscription/lib/__tests__/CalendarSubscriptionService.test.ts
Threads genericCalendarSuffixes parameter from adapter factory into findNextSubscriptionBatch calls. Test updates mock the new getGenericCalendarSuffixes() method and validate parameter propagation through subscription batching logic.
Repository Layer
packages/features/selectedCalendar/repositories/SelectedCalendarRepository.interface.ts, packages/features/selectedCalendar/repositories/SelectedCalendarRepository.ts, packages/features/selectedCalendar/repositories/SelectedCalendarRepository.test.ts
Extends findNextSubscriptionBatch method signature with optional genericCalendarSuffixes parameter. Implementation applies conditional NOT filtering on externalId to exclude calendars matching provided suffixes. Class renamed to PrismaSelectedCalendarRepository. Tests validate filtering behavior and edge cases with empty arrays.

Sequence Diagram

sequenceDiagram
    participant Service as CalendarSubscriptionService
    participant Factory as AdapterFactory
    participant Repository as SelectedCalendarRepository
    participant DB as Database

    Service->>Factory: getGenericCalendarSuffixes()
    Factory-->>Service: string[]
    
    Service->>Service: checkForNewSubscriptions()
    Service->>Repository: findNextSubscriptionBatch({<br/>take, teamIds, integrations,<br/>genericCalendarSuffixes})
    
    Repository->>Repository: Build where clause with<br/>NOT conditions for suffixes
    Repository->>DB: Query SelectedCalendar with<br/>filtering on externalId
    DB-->>Repository: SelectedCalendar[]
    Repository-->>Service: Filtered results
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Poem

🐰 Generic calendars beware, we filter them away,
Through suffixes and suffixes, they shan't spoil our day!
From Google to Office, no defaults shall stay,
Our subscriptions run cleanly, hip-hip-hooray! 🌾✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: introducing filtering logic to exclude generic calendars from subscription batches across the codebase.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch coderabbit_full_head_feat_calendarcache_-_filter_generic_calendars_from_subscription_batch_pr7

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.

@tomerqodo
Copy link
Author

@coderabbitai review

1 similar comment
@tomerqodo
Copy link
Author

@coderabbitai review

@coderabbitai
Copy link

coderabbitai bot commented Jan 30, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@tomerqodo
Copy link
Author

@coderabbitai review

@coderabbitai
Copy link

coderabbitai bot commented Jan 30, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@hussam789
Copy link

@coderabbitai review

@coderabbitai
Copy link

coderabbitai bot commented Feb 2, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

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: 1

🤖 Fix all issues with AI agents
In
`@packages/features/selectedCalendar/repositories/SelectedCalendarRepository.ts`:
- Around line 5-6: Update the test that still imports the old class name:
replace the import of SelectedCalendarRepository in the test file
(packages/features/selectedCalendar/repositories/SelectedCalendarRepository.test.ts)
with the renamed class PrismaSelectedCalendarRepository so the test imports {
PrismaSelectedCalendarRepository } from
"@calcom/features/selectedCalendar/repositories/SelectedCalendarRepository";
this will match the exported class name in PrismaSelectedCalendarRepository and
fix the failing import.
🧹 Nitpick comments (2)
packages/features/calendar-subscription/adapters/AdaptersFactory.ts (2)

19-19: Consider adding Office 365 generic calendar suffixes.

The office365_calendar entry is currently an empty array. Office 365/Outlook calendars may also have similar generic calendars (e.g., birthday calendars, holiday calendars) that should be excluded. If this is intentional (to be added later), consider adding a TODO comment. If Office 365 generic calendars are not a concern for this feature, the empty array is fine.


67-71: Consider using Object.values for cleaner iteration.

The current implementation works correctly, but using Object.values would be slightly more idiomatic and avoids the type cast:

♻️ Optional refactor using Object.values
   getGenericCalendarSuffixes(): string[] {
-    return Object.keys(GENERIC_CALENDAR_SUFFIXES).flatMap(
-      (provider) => GENERIC_CALENDAR_SUFFIXES[provider as CalendarSubscriptionProvider]
-    );
+    return Object.values(GENERIC_CALENDAR_SUFFIXES).flat();
   }

Comment on lines +5 to 6
export class PrismaSelectedCalendarRepository implements ISelectedCalendarRepository {
constructor(private prismaClient: PrismaClient) {}
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Check how SelectedCalendarRepository is exported and imported across the codebase
echo "=== Checking exports from the repository file ==="
cat packages/features/selectedCalendar/repositories/SelectedCalendarRepository.ts | head -20

echo -e "\n=== Checking all imports of SelectedCalendarRepository ==="
rg -n "import.*SelectedCalendarRepository" --type=ts

echo -e "\n=== Checking if there's an index file with re-exports ==="
fd -t f "index.ts" packages/features/selectedCalendar

Repository: agentic-review-benchmarks/cal.com-combined-coderabbit

Length of output: 3825


🏁 Script executed:

#!/bin/bash
# Check the re-export file at packages/lib/server/repository/selectedCalendar
echo "=== Checking re-export file ==="
cat packages/lib/server/repository/selectedCalendar.ts

echo -e "\n=== Checking what the test file actually imports ==="
cat packages/features/selectedCalendar/repositories/SelectedCalendarRepository.test.ts | head -10

Repository: agentic-review-benchmarks/cal.com-combined-coderabbit

Length of output: 14208


Fix test import for renamed class.

The class has been renamed from SelectedCalendarRepository to PrismaSelectedCalendarRepository in packages/features/selectedCalendar/repositories/SelectedCalendarRepository.ts. The test file at packages/features/selectedCalendar/repositories/SelectedCalendarRepository.test.ts imports the old name and will fail:

import { SelectedCalendarRepository } from "@calcom/features/selectedCalendar/repositories/SelectedCalendarRepository";

Update the test import to use the new class name PrismaSelectedCalendarRepository.

🤖 Prompt for AI Agents
In
`@packages/features/selectedCalendar/repositories/SelectedCalendarRepository.ts`
around lines 5 - 6, Update the test that still imports the old class name:
replace the import of SelectedCalendarRepository in the test file
(packages/features/selectedCalendar/repositories/SelectedCalendarRepository.test.ts)
with the renamed class PrismaSelectedCalendarRepository so the test imports {
PrismaSelectedCalendarRepository } from
"@calcom/features/selectedCalendar/repositories/SelectedCalendarRepository";
this will match the exported class name in PrismaSelectedCalendarRepository and
fix the failing import.

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.

2 participants