feat: CalendarCache - filter generic calendars from subscription batch#22
Conversation
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>
Code Review by Qodo
1. Repository class/file name mismatch
|
| import type { Prisma } from "@calcom/prisma/client"; | ||
|
|
||
| export class SelectedCalendarRepository implements ISelectedCalendarRepository { | ||
| export class PrismaSelectedCalendarRepository implements ISelectedCalendarRepository { |
There was a problem hiding this comment.
1. Repository class/file name mismatch 📘 Rule violation ✓ Correctness
• packages/features/selectedCalendar/repositories/SelectedCalendarRepository.ts exports PrismaSelectedCalendarRepository, but the filename is not PrismaSelectedCalendarRepository.ts (and does not follow the required Prisma<Entity>Repository.ts pattern). • This violates the repository naming convention requirement and reduces discoverability/consistency, and can also break imports expecting an exported class named to match the file.
Agent prompt
## Issue description
The repository file `packages/features/selectedCalendar/repositories/SelectedCalendarRepository.ts` exports `PrismaSelectedCalendarRepository`, but the filename does not match the exported class name and does not follow the required `Prisma<Entity>Repository.ts` naming convention.
## Issue Context
Compliance requires repository files to be named `Prisma<Entity>Repository.ts` and export the matching PascalCase class. The current mismatch can also break existing imports that expect `SelectedCalendarRepository` to be exported from this path.
## Fix Focus Areas
- packages/features/selectedCalendar/repositories/SelectedCalendarRepository.ts[1-6]
- packages/features/selectedCalendar/repositories/SelectedCalendarRepository.test.ts[1-5]
- apps/web/app/api/cron/calendar-subscriptions/route.ts[4-13]
- apps/web/app/api/webhooks/calendar-subscription/[provider]/route.ts[5-16]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
| import type { Prisma } from "@calcom/prisma/client"; | ||
|
|
||
| export class SelectedCalendarRepository implements ISelectedCalendarRepository { | ||
| export class PrismaSelectedCalendarRepository implements ISelectedCalendarRepository { |
There was a problem hiding this comment.
2. Broken repository export 🐞 Bug ✓ Correctness
• SelectedCalendarRepository.ts now exports PrismaSelectedCalendarRepository, but existing code still imports/instantiates SelectedCalendarRepository from the same module path. • This will cause a TypeScript compile error (missing named export) and block runtime execution for the affected Next routes and unit tests. • Impact is high because the broken imports occur in production API routes (cron + webhook handlers).
Agent prompt
## Issue description
`packages/features/selectedCalendar/repositories/SelectedCalendarRepository.ts` now exports `PrismaSelectedCalendarRepository`, but several consumers still import/instantiate `SelectedCalendarRepository` from the same module path. This breaks compilation.
## Issue Context
This repository is used by calendar-subscription cron and webhook routes; compilation failure will block those endpoints.
## Fix Focus Areas
- packages/features/selectedCalendar/repositories/SelectedCalendarRepository.ts[1-10]
- apps/web/app/api/cron/calendar-subscriptions/route.ts[4-45]
- apps/web/app/api/webhooks/calendar-subscription/[provider]/route.ts[12-65]
- packages/features/selectedCalendar/repositories/SelectedCalendarRepository.test.ts[1-55]
## Suggested approach
Option A (compat/backwards-safe):
- Keep the class name `PrismaSelectedCalendarRepository`.
- Add `export { PrismaSelectedCalendarRepository as SelectedCalendarRepository };` (or re-add a wrapper class) so existing imports keep working.
Option B (explicit rename):
- Update all imports/usages to `PrismaSelectedCalendarRepository` and ensure no code still imports `SelectedCalendarRepository`.
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
Benchmark PR from agentic-review-benchmarks#7