Skip to content

fix: recurring events with calendar connections#12250

Merged
keithwillcode merged 8 commits intomainfrom
fix/recurring-booking-improvements
Nov 7, 2023
Merged

fix: recurring events with calendar connections#12250
keithwillcode merged 8 commits intomainfrom
fix/recurring-booking-improvements

Conversation

@CarinaWolli
Copy link
Copy Markdown
Member

@CarinaWolli CarinaWolli commented Nov 6, 2023

What does this PR do?

Fixes that when booking a recurring event with a calendar connection it was always throwing 'no available users found':
Screenshot 2023-11-06 at 19 30 57

This error was also thrown when user was available on all the recurring dates.

Type of change

  • Bug fix (non-breaking change which fixes an issue)

How should this be tested?

  • Connect Google Calendar -> toggle same calendar to check for conflicts as the one that is set to add the events on
  • Create recurring event type
  • Book a slot were you know that all future slot are available too
  • This should pass now

Mandatory Tasks

  • Make sure you have self-reviewed the code. A decent size PR without self-review might be rejected.

Checklist

  • I haven't read the contributing guide
  • My code doesn't follow the style guidelines of this project
  • I haven't commented my code, particularly in hard-to-understand areas
  • I haven't checked if my PR needs changes to the documentation
  • I haven't checked if my changes generate no new warnings
  • I haven't added tests that prove my fix is effective or that my feature works
  • I haven't checked if new and existing unit tests pass locally with my changes

@vercel
Copy link
Copy Markdown

vercel Bot commented Nov 6, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
ai ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 7, 2023 2:41pm
api ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 7, 2023 2:41pm
dev ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 7, 2023 2:41pm
4 Ignored Deployments
Name Status Preview Comments Updated (UTC)
cal ⬜️ Ignored (Inspect) Visit Preview Nov 7, 2023 2:41pm
cal-demo ⬜️ Ignored (Inspect) Visit Preview Nov 7, 2023 2:41pm
qa ⬜️ Ignored (Inspect) Visit Preview Nov 7, 2023 2:41pm
ui ⬜️ Ignored (Inspect) Visit Preview Nov 7, 2023 2:41pm

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Nov 6, 2023

Thank you for following the naming conventions! 🙏 Feel free to join our discord and post your PR link to collect XP and win prizes!

@zomars zomars added the core area: core, team members only label Nov 6, 2023
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Nov 6, 2023

📦 Next.js Bundle Analysis for @calcom/web

This analysis was generated by the Next.js Bundle Analysis action. 🤖

This PR introduced no changes to the JavaScript bundle! 🙌

@deploysentinel
Copy link
Copy Markdown

deploysentinel Bot commented Nov 6, 2023

Current Playwright Test Results Summary

✅ 313 Passing - ⚠️ 7 Flaky

Run may still be in progress, this comment will be updated as current testing workflow or job completes...

(Last updated on 11/07/2023 02:52:50pm UTC)

Run Details

Running Workflow PR Update on Github Actions

Commit: f61971a

Started: 11/07/2023 02:43:19pm UTC

⚠️ Flakes

📄   apps/web/playwright/event-types.e2e.ts • 1 Flake

Test Case Results

Test Case Last 7 days Failures Last 7 days Flakes
Event Types tests user can add multiple organizer address
Retry 1Initial Attempt
0.44% (1) 1 / 228 run
failed over last 7 days
10.09% (23) 23 / 228 runs
flaked over last 7 days

📄   apps/web/playwright/teams.e2e.ts • 2 Flakes

Top 1 Common Error Messages

null

2 Test Cases Affected

Test Case Results

Test Case Last 7 days Failures Last 7 days Flakes
Teams - NonOrg Can create teams via Wizard
Retry 1Initial Attempt
0% (0) 0 / 215 runs
failed over last 7 days
1.40% (3) 3 / 215 runs
flaked over last 7 days
Teams - NonOrg Non admin team members cannot create team in org
Retry 1Initial Attempt
0% (0) 0 / 215 runs
failed over last 7 days
40.47% (87) 87 / 215 runs
flaked over last 7 days

📄   apps/web/playwright/insights.e2e.ts • 2 Flakes

Top 1 Common Error Messages

null

2 Test Cases Affected

Test Case Results

Test Case Last 7 days Failures Last 7 days Flakes
Insights should be able to go to insights as members
Retry 1Initial Attempt
0% (0) 0 / 228 runs
failed over last 7 days
4.82% (11) 11 / 228 runs
flaked over last 7 days
Insights should test download button
Retry 1Initial Attempt
0% (0) 0 / 228 runs
failed over last 7 days
6.14% (14) 14 / 228 runs
flaked over last 7 days

📄   packages/embeds/embed-core/playwright/tests/inline.e2e.ts • 1 Flake

Test Case Results

Test Case Last 7 days Failures Last 7 days Flakes
Inline Iframe Inline Iframe - Configured with Dark Theme
Retry 1Initial Attempt
1.31% (3) 3 / 229 runs
failed over last 7 days
28.38% (65) 65 / 229 runs
flaked over last 7 days

📄   packages/embeds/embed-core/playwright/tests/action-based.e2e.ts • 1 Flake

Test Case Results

Test Case Last 7 days Failures Last 7 days Flakes
Popup Tests should be able to reschedule
Retry 1Initial Attempt
20.51% (48) 48 / 234 runs
failed over last 7 days
73.93% (173) 173 / 234 runs
flaked over last 7 days

View Detailed Build Results


@CarinaWolli CarinaWolli marked this pull request as ready for review November 6, 2023 19:59
Comment thread packages/lib/parse-dates.ts Outdated
const dateStrings = times.map((t) => {
// finally; show in local timeZone again
return processDate(t.tz(timeZone), language, { selectedTimeFormat, withDefaultTimeFormat });
return processDate(t.tz(timeZone), language, { selectedTimeFormat, withDefaultTimeFormat }, timeZone);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

What is the exact bug that this change fixes?

Comment thread packages/lib/parse-dates.ts Outdated
date: string | null | Dayjs,
language: string,
options?: ExtraOptions,
timeZone?: string
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

If we really need timezone to show the correct time here, shouldn't we make it required and fix everywhere it's missing.

} else {
foundConflict = checkForConflicts(bufferedBusyTimes, input.dateFrom, duration);
}
foundConflict = checkForConflicts(bufferedBusyTimes, input.dateFrom, duration);
Copy link
Copy Markdown
Member

@hariombalhara hariombalhara Nov 7, 2023

Choose a reason for hiding this comment

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

The change looks good. I was already removing it as part of https://github.com/calcom/cal.com/pull/11774/files

But the interesting thing is that I was thinking that it was dead code but actually it was failing some bookings.
Did some investigation as to how just enabling a calendar was failing Recurring bookings

  • When Calendar is enabled, we don't just fetch the busyTimes for the current slot being booked but instead we fetch till the end of the month(some weird reason for this). This isn't true for busyTimes fetched from DB. There it's just for the range of the timeslot being booked as expected. The behaviour changed here 5 months back. So, I believe it has been broken for 5 straight months now.
  • Due to this, when a single timeslot was checked for conflicts with busytimes, it was actually checking conflicts with busyTime of a recurring timeslot that was just booked in the previous iteration and thus it was always failing.

So, great find @CarinaWolli 👏

Copy link
Copy Markdown
Member

@hariombalhara hariombalhara left a comment

Choose a reason for hiding this comment

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

Requesting changes to get clarity on timezone related change, otherwise it's good.

@keithwillcode
Copy link
Copy Markdown
Contributor

Great find, @CarinaWolli. Any tests we could add to make sure this continues to work?

// DONE: Decreased computational complexity from O(2^n) to O(n) by refactoring this loop to stop
// running at the first unavailable time.
let i = 0;
while (!foundConflict && i < allBookingDates.length) {
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The issue here was that every recurring date called the handler starting with with the last booking (see: book/recurring-event.ts)

So when the handler was called for the first booking (recurringDatesInfo?.currentRecurringIndex === 0) the calendar events for the other dates already existed and the checkForConflicts function found a conflict

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Wow

: options?.selectedTimeFormat || detectBrowserTimeFormat
);
return `${formattedTime}, ${dayjs(date).toDate().toLocaleString(language, { dateStyle: "full" })}`;
return `${formattedTime}, ${dayjs(date)
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Dates on booking page were shown incorrectly (day)

Example:
Should show Nov 8, 15 and 22. But shows:
Screenshot 2023-11-06 at 14 58 07

@CarinaWolli
Copy link
Copy Markdown
Member Author

Great find, @CarinaWolli. Any tests we could add to make sure this continues to work?

I don't think we have a setup yet for testing calendar connections. I think @joeauyeung is working on that. That would be needed to test this

@keithwillcode keithwillcode added the bookings area: bookings, availability, timezones, double booking label Nov 7, 2023
@keithwillcode
Copy link
Copy Markdown
Contributor

Great find, @CarinaWolli. Any tests we could add to make sure this continues to work?

I don't think we have a setup yet for testing calendar connections. I think @joeauyeung is working on that. That would be needed to test this

Ok. I thought by looking at the code it would be possible for us to unit test/mock the data this function receives, not necessarily coming from a real calendar connection.

We'll push this PR through to get the bug fixed but let's look into this possibility in a follow-up PR.

@keithwillcode keithwillcode self-requested a review November 7, 2023 14:45
@keithwillcode keithwillcode enabled auto-merge (squash) November 7, 2023 14:46
@keithwillcode keithwillcode dismissed hariombalhara’s stale review November 7, 2023 15:09

Reason for change requested was addressed

@keithwillcode keithwillcode merged commit 8b89d66 into main Nov 7, 2023
@keithwillcode keithwillcode deleted the fix/recurring-booking-improvements branch November 7, 2023 15:09
@keithwillcode keithwillcode linked an issue Nov 11, 2023 that may be closed by this pull request
zomars pushed a commit that referenced this pull request Jan 29, 2024
Co-authored-by: CarinaWolli <wollencarina@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bookings area: bookings, availability, timezones, double booking core area: core, team members only High priority Created by Linear-GitHub Sync

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[CAL-2517] Recurring Event - Error while booking a meeting.

4 participants