Skip to content

Conversation

@Udit-takkar
Copy link
Contributor

@Udit-takkar Udit-takkar commented Jan 23, 2026

What does this PR do?

This PR refactors calendar event builder and prevents re assignment of evt

Mandatory Tasks (DO NOT REMOVE)

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

How should this be tested?


Summary by cubic

Refactored calendar event creation to build complete events in one pass using CalendarEventBuilder, covering team, recurring, and video call data. This simplifies booking logic and reduces post-build mutations and error paths.

  • Refactors
    • Added CalendarEventBuilder.withConditional for optional fields.
    • Unified team handling via computeTeamData and builder.withTeam; merged team destination calendars.
    • Updated round-robin member selection to include all non-fixed users.
    • Passed recurring config/count directly with builder.withRecurring and withRecurringEventId.
    • Centralized video call data with builder.withVideoCallDataFromReferences and removed addVideoCallDataToEvent.
    • Builder.build now throws on missing required fields to surface errors early.

Written for commit a644ff1. Summary will update on new commits.

Comment on lines -1849 to -1856
if (reqBody.recurringEventId && eventType.recurringEvent) {
// Overriding the recurring event configuration count to be the actual number of events booked for
// the recurring event (equal or less than recurring event configuration count)
eventType.recurringEvent = Object.assign({}, eventType.recurringEvent, { count: recurringCount });
evt.recurringEvent = eventType.recurringEvent;
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moved this where evt is being created

Comment on lines -1573 to -1605

if (input.bookingData.thirdPartyRecurringEventId) {
const updatedEvt = CalendarEventBuilder.fromEvent(evt)
?.withRecurringEventId(input.bookingData.thirdPartyRecurringEventId)
.build();

if (!updatedEvt) {
throw new HttpError({
statusCode: 400,
message: "Failed to build event with recurring event ID due to missing required fields",
});
}

evt = updatedEvt;
}

if (isTeamEventType) {
const teamEvt = await buildEventForTeamEventType({
existingEvent: evt,
schedulingType: eventType.schedulingType,
users,
team: eventType.team,
organizerUser,
});

if (!teamEvt) {
throw new HttpError({ statusCode: 400, message: "Failed to build team event" });
}

evt = teamEvt;
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have created a withConditional method that would help us do this inside calendar event builder

@Udit-takkar Udit-takkar marked this pull request as ready for review January 24, 2026 12:45
@Udit-takkar Udit-takkar requested a review from a team as a code owner January 24, 2026 12:45
@graphite-app graphite-app bot added enterprise area: enterprise, audit log, organisation, SAML, SSO core area: core, team members only labels Jan 24, 2026
@graphite-app graphite-app bot requested a review from a team January 24, 2026 12:46
@Udit-takkar Udit-takkar added this to the v6.2 milestone Jan 24, 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 4 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="packages/features/CalendarEventBuilder.ts">

<violation number="1" location="packages/features/CalendarEventBuilder.ts:556">
P2: withConditional should skip undefined data as well as null; currently undefined still triggers apply() and violates the NonNullable<T> assumption.</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

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 (changes from recent commits).

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="packages/features/CalendarEventBuilder.ts">

<violation number="1" location="packages/features/CalendarEventBuilder.ts:571">
P2: Use ErrorWithCode (or ErrorWithCode.Factory.BadRequest) in packages/features instead of HttpError so errors are translated consistently by middleware.</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

@devin-ai-integration
Copy link
Contributor

Reviewed the Cubic AI feedback for the issue at packages/features/CalendarEventBuilder.ts:571 regarding using ErrorWithCode instead of HttpError.

The confidence score for this issue is 7/10, which is below the 9/10 threshold required for automated fixes. Skipping this issue per the review guidelines.

If the PR author believes this change should be made, they can manually update the code to use ErrorWithCode.Factory.BadRequest() instead of HttpError for consistent error translation by middleware.

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

Labels

core area: core, team members only enterprise area: enterprise, audit log, organisation, SAML, SSO size/XL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants