Skip to content

Conversation

@ThyMinimalDev
Copy link
Contributor

@ThyMinimalDev ThyMinimalDev commented Jan 16, 2026

What does this PR do?

This PR ensures that default selected calendars (in addition to destination calendars) are set when the calendars background job runs in API v2.

Previously, the CalendarsProcessor called getCalendars(userId) which only ensured default destination calendars were set. Now it passes true for a new ensureDefaultSelectedCalendars parameter, which sets onboarding: true when calling getConnectedDestinationCalendarsAndEnsureDefaultsInDb from platform libraries. This triggers the full onboarding behavior that also creates default selected calendars.

The default value remains false to preserve existing behavior for other callers and caching.

Updates since last revision

Fixed cache bypass logic: When ensureDefaultSelectedCalendars is true, the method now correctly bypasses the cache to ensure the defaults logic actually runs. Previously, cached data would be returned before the ensure-defaults logic could execute, making the flag ineffective when cache was populated.

Mandatory Tasks (DO NOT REMOVE)

  • I have self-reviewed the code (A decent size PR without self-review might be rejected).
  • I have updated the developer docs in /docs if this PR makes changes that would require a documentation change. N/A - internal API change only.
  • I confirm automated tests are in place that prove my fix is effective or that my feature works.

How should this be tested?

  1. Connect a calendar integration (e.g., Google Calendar) for a user via API v2
  2. Verify that the calendars background job runs and creates both:
    • Default destination calendar
    • Default selected calendars
  3. Verify that direct calls to getCalendars(userId) (without the second parameter) still work as before and don't trigger the onboarding behavior
  4. Verify that when ensureDefaultSelectedCalendars=true, the cache is bypassed and defaults are ensured even if cached data exists

Human Review Checklist

  • Verify that onboarding: true is the correct flag to trigger default selected calendar creation in getConnectedDestinationCalendarsAndEnsureDefaultsInDb
  • Confirm the cache bypass behavior is correct: when ensureDefaultSelectedCalendars=true, we intentionally skip the cache to ensure defaults are set
  • Verify that normal calls (with ensureDefaultSelectedCalendars=false or omitted) still use the cache as expected

@ThyMinimalDev ThyMinimalDev requested a review from a team as a code owner January 16, 2026 15:46
@graphite-app graphite-app bot added core area: core, team members only foundation labels Jan 16, 2026
@devin-ai-integration devin-ai-integration bot changed the title chore: ensure default selected calendars handleEnsureDefaultCalendars chore: ensure default selected calendars in calendars processor job Jan 16, 2026
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

1 issue found across 2 files

Prompt for AI agents (all issues)

Check if these issues are valid — if so, understand the root cause of each and fix them.


<file name="apps/api/v2/src/ee/calendars/services/calendars.service.ts">

<violation number="1" location="apps/api/v2/src/ee/calendars/services/calendars.service.ts:54">
P2: `ensureDefaultSelectedCalendars` is ignored whenever cached data exists, because the method returns the cache before running the ensure-defaults logic. This prevents onboarding flows from actually ensuring defaults if the cache was already populated.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

@github-actions
Copy link
Contributor

Devin AI is addressing Cubic AI's review feedback

A Devin session has been created to address the issues identified by Cubic AI.

View Devin Session

When ensureDefaultSelectedCalendars is true, the cache should be bypassed
to ensure the defaults logic actually runs. Previously, cached data would
be returned before the ensure-defaults logic could execute.

Addresses Cubic AI review feedback (confidence 9/10).

Co-Authored-By: unknown <>
@github-actions
Copy link
Contributor

github-actions bot commented Jan 16, 2026

E2E results are ready!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants