Skip to content

Conversation

@tomerqodo
Copy link

@tomerqodo tomerqodo commented Jan 22, 2026

Benchmark PR from qodo-benchmark#702

Summary by CodeRabbit

  • New Features
    • Calendar subscriptions now automatically exclude generic calendars based on provider-specific suffix patterns, giving users more control over which calendars are included in subscription operations.

✏️ Tip: You can customize this high-level summary in your review settings.

devin-ai-integration bot and others added 2 commits January 21, 2026 15:41
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 22, 2026

Walkthrough

The PR introduces generic calendar suffix filtering throughout the calendar subscription system. A new constant maps calendar providers to suffix strings to exclude. The adapter factory exposes these suffixes. The calendar subscription service retrieves and passes them to the repository. The repository's findNextSubscriptionBatch method now accepts an optional genericCalendarSuffixes parameter and filters results by excluding records whose external IDs end with the provided suffixes.

Changes

Cohort / File(s) Summary
Adapter Factory - Suffix Definitions
packages/features/calendar-subscription/adapters/AdaptersFactory.ts
Introduced GENERIC_CALENDAR_SUFFIXES constant mapping calendar providers to suffix arrays. Extended AdapterFactory interface with getGenericCalendarSuffixes(): string[] method. Implemented in DefaultAdapterFactory to return concatenated suffixes from all providers.
Service Layer Integration
packages/features/calendar-subscription/lib/CalendarSubscriptionService.ts
Updated findNextSubscriptionBatch call in checkForNewSubscriptions to include genericCalendarSuffixes parameter retrieved from AdapterFactory.getGenericCalendarSuffixes().
Repository Interface & Implementation
packages/features/selectedCalendar/repositories/SelectedCalendarRepository.interface.ts,
packages/features/selectedCalendar/repositories/SelectedCalendarRepository.ts
Added optional genericCalendarSuffixes?: string[] parameter to ISelectedCalendarRepository.findNextSubscriptionBatch signature with JSDoc. Renamed class from SelectedCalendarRepository to PrismaSelectedCalendarRepository. Implemented filtering logic in query to exclude records whose externalId ends with any provided suffix.
Test Coverage
packages/features/calendar-subscription/lib/__tests__/CalendarSubscriptionService.test.ts,
packages/features/selectedCalendar/repositories/SelectedCalendarRepository.test.ts
Added getGenericCalendarSuffixes() mock method to AdapterFactory tests. Updated test payloads to include genericCalendarSuffixes parameter. Added test case for filtering behavior when suffixes are provided and edge cases for empty arrays.

Sequence Diagram

sequenceDiagram
    participant CS as CalendarSubscriptionService
    participant AF as AdapterFactory
    participant Repo as SelectedCalendarRepository
    participant DB as Database
    
    CS->>AF: getGenericCalendarSuffixes()
    AF-->>CS: string[]
    
    CS->>Repo: findNextSubscriptionBatch({<br/>  take, teamIds, integrations,<br/>  genericCalendarSuffixes<br/>})
    
    Repo->>Repo: Build query with filters
    Note over Repo: AND NOT externalId<br/>endsWith suffixes
    
    Repo->>DB: SELECT * WHERE filters
    DB-->>Repo: SelectedCalendar[]
    Repo-->>CS: filtered results
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 Through calendars we hop and skip,

Filtering suffixes with a flip,

Generic bloat we strip away,

Subscriptions clean and trim to stay! 📅✨

🚥 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 pull request title clearly and specifically summarizes the main change: adding filtering for generic calendars in the subscription batch functionality.
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

Comment @coderabbitai help to get the list of available commands and usage tips.

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
packages/features/selectedCalendar/repositories/SelectedCalendarRepository.test.ts (1)

3-3: Update import to match the renamed class.

The test imports SelectedCalendarRepository, but the implementation file only exports PrismaSelectedCalendarRepository. Update line 3 to import the correct class name:

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

Also update line 50 and 53 where the type and instantiation use SelectedCalendarRepository to use PrismaSelectedCalendarRepository instead.

🤖 Fix all issues with AI agents
In
`@packages/features/selectedCalendar/repositories/SelectedCalendarRepository.ts`:
- Around line 23-27: Change the parameter type in SelectedCalendarRepository
(the function/method that destructures { take, teamIds, integrations,
genericCalendarSuffixes }) to make integrations optional (integrations?:
string[]) to match SelectedCalendarRepository.interface.ts, and update any logic
inside that function (query building or filters that reference integrations) to
guard for undefined—e.g., check integrations && integrations.length (or
integrations?.length) before using it or build the query branch that handles
integrations being undefined/omitted.
🧹 Nitpick comments (2)
packages/features/calendar-subscription/adapters/AdaptersFactory.ts (1)

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

The current implementation works correctly, but using Object.values avoids the type assertion.

♻️ Suggested simplification
  getGenericCalendarSuffixes(): string[] {
-   return Object.keys(GENERIC_CALENDAR_SUFFIXES).flatMap(
-     (provider) => GENERIC_CALENDAR_SUFFIXES[provider as CalendarSubscriptionProvider]
-   );
+   return Object.values(GENERIC_CALENDAR_SUFFIXES).flat();
  }
packages/features/selectedCalendar/repositories/SelectedCalendarRepository.ts (1)

41-45: Minor: Redundant optional chaining after truthy check.

The ?. in genericCalendarSuffixes?.map on line 42 is unnecessary since genericCalendarSuffixes?.length on line 41 already ensures the array is defined and non-empty.

♻️ Suggested cleanup
-       AND: genericCalendarSuffixes?.length
-         ? genericCalendarSuffixes?.map((suffix) => ({
+       AND: genericCalendarSuffixes?.length
+         ? genericCalendarSuffixes.map((suffix) => ({
              NOT: { externalId: { endsWith: suffix } },
            }))
          : undefined,
📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8fde1c3 and c497df4.

📒 Files selected for processing (6)
  • packages/features/calendar-subscription/adapters/AdaptersFactory.ts
  • packages/features/calendar-subscription/lib/CalendarSubscriptionService.ts
  • packages/features/calendar-subscription/lib/__tests__/CalendarSubscriptionService.test.ts
  • packages/features/selectedCalendar/repositories/SelectedCalendarRepository.interface.ts
  • packages/features/selectedCalendar/repositories/SelectedCalendarRepository.test.ts
  • packages/features/selectedCalendar/repositories/SelectedCalendarRepository.ts
🧰 Additional context used
🧬 Code graph analysis (1)
packages/features/selectedCalendar/repositories/SelectedCalendarRepository.ts (1)
packages/features/selectedCalendar/repositories/SelectedCalendarRepository.interface.ts (1)
  • ISelectedCalendarRepository (3-67)
🔇 Additional comments (5)
packages/features/calendar-subscription/lib/CalendarSubscriptionService.ts (1)

391-396: LGTM!

The integration of genericCalendarSuffixes into the subscription batch query is clean and correctly sources the suffixes from the adapter factory.

packages/features/calendar-subscription/lib/__tests__/CalendarSubscriptionService.test.ts (1)

115-121: LGTM!

The mock setup for getGenericCalendarSuffixes correctly mirrors the production GENERIC_CALENDAR_SUFFIXES values, and the test expectations throughout properly validate the integration.

packages/features/selectedCalendar/repositories/SelectedCalendarRepository.test.ts (1)

202-236: LGTM!

The new test case properly validates the suffix filtering behavior, verifying that the AND clause contains the correct NOT endsWith conditions for each provided suffix.

packages/features/calendar-subscription/adapters/AdaptersFactory.ts (1)

7-20: LGTM!

The GENERIC_CALENDAR_SUFFIXES constant is well-documented and properly centralizes the exclusion patterns per provider. The empty array for office365_calendar provides a clear extension point for future additions.

packages/features/selectedCalendar/repositories/SelectedCalendarRepository.interface.ts (1)

26-36: LGTM!

The interface correctly adds genericCalendarSuffixes as an optional parameter with appropriate JSDoc documentation.

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.

Comment on lines 23 to +27
}: {
take: number;
teamIds: number[];
integrations: string[];
genericCalendarSuffixes?: string[];
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Type mismatch: integrations is required here but optional in interface.

The interface at SelectedCalendarRepository.interface.ts declares integrations?: string[] as optional, but this implementation declares it as required (integrations: string[]). This mismatch could cause type errors for callers expecting to omit the parameter.

🔧 Suggested fix
  }: {
    take: number;
    teamIds: number[];
-   integrations: string[];
+   integrations?: string[];
    genericCalendarSuffixes?: string[];
  }) {

Then update the query to handle undefined:

      where: {
-       integration: { in: integrations },
+       integration: integrations?.length ? { in: integrations } : undefined,
🤖 Prompt for AI Agents
In
`@packages/features/selectedCalendar/repositories/SelectedCalendarRepository.ts`
around lines 23 - 27, Change the parameter type in SelectedCalendarRepository
(the function/method that destructures { take, teamIds, integrations,
genericCalendarSuffixes }) to make integrations optional (integrations?:
string[]) to match SelectedCalendarRepository.interface.ts, and update any logic
inside that function (query building or filters that reference integrations) to
guard for undefined—e.g., check integrations && integrations.length (or
integrations?.length) before using it or build the query branch that handles
integrations being undefined/omitted.

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