Skip to content

Date override fixes#8330

Merged
emrysal merged 11 commits intomainfrom
fix/round-robin-date-override
Apr 18, 2023
Merged

Date override fixes#8330
emrysal merged 11 commits intomainfrom
fix/round-robin-date-override

Conversation

@CarinaWolli
Copy link
Copy Markdown
Member

@CarinaWolli CarinaWolli commented Apr 17, 2023

What does this PR do?

This PR fixes that date overrides of fixed hosts are taken into account for round-robin events. This prevents round-robin events being booked where the fixed hosts are unavailable.

This PR also fixes that date overrides didn't adjust to different timezones. If the organizer has a date override from 10-11 UTC it always showed the slots from 10-11 open no matter what timezone the attendee has.

Fixes #8207
Fixes #8329

Fixes: #8273

Environment: Staging(main branch) / Production

Type of change

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

How should this be tested?

Date overrides for fixed hosts (round-robin):

  • Create a round-robin event with one fixed host and host round-robin host
  • Create a date override for fixed host (round-robin host should also be available at that time)
  • Check available slots of event on the day of the date override, it should only show the slots where fixed host is available
  • Test that with different time zones on booking page and on the availabilities of fixed and round-robin host

Date override timezones issue:

  • Create a date override
  • Go to the booking page of a personal event
  • Change the timezone to a different one that the availability with the date override is
  • See the available slots of the day with the date override change accordingly
  • Also test with different timezones here

@vercel
Copy link
Copy Markdown

vercel bot commented Apr 17, 2023

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

Name Status Preview Comments Updated (UTC)
cal ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 18, 2023 3:11pm
ui ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 18, 2023 3:11pm

@github-actions github-actions bot added High priority Created by Linear-GitHub Sync bookings area: bookings, availability, timezones, double booking 🐛 bug Something isn't working labels Apr 17, 2023
}
);

const scheduleForEventOnADayWithDateOverrideDifferentTimezone = await getSchedule(
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.

Here attendee has a different timezone than the organizer. This test would have failed before and fixes #8329

const inviteeUtcOffset = dayjs(override.start.toString()).tz(timeZone).utcOffset();
const offset = inviteeUtcOffset - organizerUtcOffset;

return {
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 times of activeOverrides show the date override in the organizer's availability timezone, we return the overrides in the time of the timezone set on the booking page

//check if date override for slot exists
let dateOverrideExist = false;

if (
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.

If a date override exists on the day of the slot and the slot starts before that or ends after that date override it will return false (not available)

@CarinaWolli
Copy link
Copy Markdown
Member Author

CarinaWolli commented Apr 17, 2023

@hariombalhara I think you created the getSchedule tests, right? It uses createBookingScenario to create the mock data, can I use that to create a round-robin event with a fixed host?

@hariombalhara
Copy link
Copy Markdown
Member

createBookingScenario

Screenshot 2023-04-17 at 6 40 45 PM

Yeah, I think that should be possible. I am mocking and faking the result of prisma calls. You can fake anything being returned from DB for EventType, Booking, App, User tables.

@CarinaWolli CarinaWolli requested a review from emrysal April 17, 2023 13:42
@github-actions
Copy link
Copy Markdown
Contributor

📦 Next.js Bundle Analysis for @calcom/web

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

Two Pages Changed Size

The following pages changed size from the code in this PR compared to its base branch:

Page Size (compressed) First Load % of Budget (350 KB)
/apps/[slug]/[...pages] 389.04 KB 620.33 KB 177.24% (🟢 -0.18%)
/auth/setup 81.57 KB 312.87 KB 89.39% (🟢 -0.17%)
Details

Only the gzipped size is provided here based on an expert tip.

First Load is the size of the global bundle plus the bundle for the individual page. If a user were to show up to your website and land on a given page, the first load size represents the amount of javascript that user would need to download. If next/link is used, subsequent page loads would only need to download that page's bundle (the number in the "Size" column), since the global bundle has already been downloaded.

Any third party scripts you have added directly to your app using the <script> tag are not accounted for in this analysis

The "Budget %" column shows what percentage of your performance budget the First Load total takes up. For example, if your budget was 100kb, and a given page's first load size was 10kb, it would be 10% of your budget. You can also see how much this has increased or decreased compared to the base branch of your PR. If this percentage has increased by 20% or more, there will be a red status indicator applied, indicating that special attention should be given to this. If you see "+/- <0.01%" it means that there was a change in bundle size, but it is a trivial enough amount that it can be ignored.

@deploysentinel
Copy link
Copy Markdown

deploysentinel bot commented Apr 17, 2023

Current Playwright Test Results Summary

✅ 67 Passing - ⚠️ 2 Flaky

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

(Last updated on 04/18/2023 03:14:28pm UTC)

Run Details

Running Workflow PR Update on Github Actions

Commit: ee38fd2

Started: 04/18/2023 03:08:13pm UTC

⚠️ Flakes

📄   apps/web/playwright/manage-booking-questions.e2e.ts • 1 Flake

Test Case Results

Test Case Last 7 days Failures Last 7 days Flakes
Manage Booking Questions For User EventType Do a booking with a user added question and verify a few thing in b/w
Retry 1Initial Attempt
1.22% (3) 3 / 246 runs
failed over last 7 days
3.25% (8) 8 / 246 runs
flaked over last 7 days

📄   apps/web/playwright/embed-code-generator.e2e.ts • 1 Flake

Test Case Results

Test Case Last 7 days Failures Last 7 days Flakes
Embed Code Generator Tests Event Type Edit Page open Embed Dialog for the Event Type
Retry 1Initial Attempt
3.16% (8) 8 / 253 runs
failed over last 7 days
22.92% (58) 58 / 253 runs
flaked over last 7 days

View Detailed Build Results


@CarinaWolli CarinaWolli marked this pull request as ready for review April 18, 2023 08:04
@CarinaWolli
Copy link
Copy Markdown
Member Author

Tests for the fix of #8207 are still missing. I am working on it

@CarinaWolli CarinaWolli requested a review from a team April 18, 2023 08:08
Comment on lines +212 to +213
const organizerUtcOffset = dayjs(override.start.toString()).tz(organizerTimeZone).utcOffset();
const inviteeUtcOffset = dayjs(override.start.toString()).tz(timeZone).utcOffset();
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.

NIT

Suggested change
const organizerUtcOffset = dayjs(override.start.toString()).tz(organizerTimeZone).utcOffset();
const inviteeUtcOffset = dayjs(override.start.toString()).tz(timeZone).utcOffset();
const organizerUtcOffset = dayjs(override.start).tz(organizerTimeZone).utcOffset();
const inviteeUtcOffset = dayjs(override.start).tz(timeZone).utcOffset();

Not tested but do we need this to be toString? We seem to just use override.start/end everywhere

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.

toString and non-toString are basically identical. for Dayjs purposes I'd probably do, but it's probably all the same:

Dayjs.utc(override.start.toISOString()).tz(...

Copy link
Copy Markdown
Member

@sean-brydon sean-brydon left a comment

Choose a reason for hiding this comment

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

Nice work <3 UTC gets complicated i can see this one being tricky

@CarinaWolli CarinaWolli marked this pull request as draft April 18, 2023 10:09
@CarinaWolli CarinaWolli marked this pull request as ready for review April 18, 2023 10:25
@github-actions
Copy link
Copy Markdown
Contributor

📦 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! 🙌

Copy link
Copy Markdown
Contributor

@emrysal emrysal left a comment

Choose a reason for hiding this comment

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

Two comments, second one is possibly broken but waiting for @CarinaWolli to review my comments.

Comment on lines +212 to +213
const organizerUtcOffset = dayjs(override.start.toString()).tz(organizerTimeZone).utcOffset();
const inviteeUtcOffset = dayjs(override.start.toString()).tz(timeZone).utcOffset();
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.

toString and non-toString are basically identical. for Dayjs purposes I'd probably do, but it's probably all the same:

Dayjs.utc(override.start.toISOString()).tz(...

const timeSlots: ReturnType<typeof getTimeSlots> = [];

const organizerTimeZone =
eventType.timeZone || eventType?.schedule?.timeZone || userAvailability?.[0]?.timeZone;
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.

I'm not sure userAvailability?.[0] works; I think you need to involve the defaultSchedule here

Copy link
Copy Markdown
Contributor

@emrysal emrysal left a comment

Choose a reason for hiding this comment

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

Approve as it was already an issue @CarinaWolli

@CarinaWolli CarinaWolli marked this pull request as draft April 18, 2023 13:54
@CarinaWolli
Copy link
Copy Markdown
Member Author

Putting it in draft as I think I just found another issue with timezones. Testing right now

time: slot.time,
...schedule,
...availabilityCheckProps,
organizerTimeZone: schedule.timeZone,
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.

@alex we want to have the schedule's timezone here

@CarinaWolli CarinaWolli marked this pull request as ready for review April 18, 2023 15:00
@github-actions
Copy link
Copy Markdown
Contributor

📦 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! 🙌

@emrysal emrysal merged commit 3ef3284 into main Apr 18, 2023
@emrysal emrysal deleted the fix/round-robin-date-override branch April 18, 2023 15:21
CarinaWolli pushed a commit that referenced this pull request Apr 19, 2023
PeerRich pushed a commit that referenced this pull request Apr 19, 2023
This reverts commit 3ef3284.

Co-authored-by: CarinaWolli <wollencarina@gmail.com>
@PeerRich PeerRich added the core area: core, team members only label Jul 24, 2023
Copy link
Copy Markdown

@mfeuerstein mfeuerstein left a comment

Choose a reason for hiding this comment

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

PR Review — approved

Reviewed 4 files. 0 high-severity issues found. Verdict: approved.

packages/types/schedule.d.ts (low)

  • Reviewed packages/types/schedule.d.ts — looks good

packages/trpc/server/routers/viewer/slots.ts (low)

  • Reviewed packages/trpc/server/routers/viewer/slots.ts — looks good

apps/web/test/lib/getSchedule.test.ts (low)

  • Reviewed apps/web/test/lib/getSchedule.test.ts — looks good

packages/lib/slots.ts (low)

  • Reviewed packages/lib/slots.ts — looks good

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 🐛 bug Something isn't working core area: core, team members only High priority Created by Linear-GitHub Sync

Projects

None yet

6 participants