cal.com icon indicating copy to clipboard operation
cal.com copied to clipboard

Collective events are now considered from getBusyTimes booking query

Open AaronPresley opened this issue 2 years ago • 3 comments

What does this PR do?

Fixes #6374

This PR updates the getBusyTimes query to consider a user busy within a given time period if:

  • There is a booking owned by this user (previous functionality)
  • There is a booking with an eventType.id in which this user is a host

Environment: Staging(main branch) / Production

Type of change

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

How should this be tested?

  1. Clean your DB by running yarn db-nuke from within packages/prisma
  2. Boot the app from the root with yarn dx
  3. Login as [email protected] / teampro
  4. Create a new Event Type for the Team Pro user
  5. Edit Collective Seeded Team Event > Assignment > include the Team Pro user > Save
  6. In an incognito browser, book a meeting under Collective Seeded Team Event
  7. In an incognito browser, check the availability for the Event Type you created in Step 4

In Production you will see that the Team Pro user is considered available for the time slot booked in Step 6

In this PR you will see that the Team Pro user is considered unavailable for the time slot booked in Step 3

Checklist

  • I have added tests that prove my fix is effective or that my feature works
  • I have updated existing unit tests to pass locally with my changes

AaronPresley avatar Feb 07 '23 00:02 AaronPresley

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

1 Ignored Deployment
Name Status Preview Comments Updated
ui ⬜️ Ignored (Inspect) Feb 7, 2023 at 0:37AM (UTC)

vercel[bot] avatar Feb 07 '23 00:02 vercel[bot]

@AaronPresley is attempting to deploy a commit to the cal Team on Vercel.

A member of the Team first needs to authorize it.

vercel[bot] avatar Feb 07 '23 00:02 vercel[bot]

@emrysal @PeerRich this one's ready for review 👍 It took a while to crawl through the schema to figure out the best way to gather this data, but I eventually figured out that the Host table is the best source. I've left a lot of comments in the code itself to explain the flow.

Also, I noticed there's some performance testing around this function (named prismaBookingGetStart and prismaBookingGetEnd). I'm guessing there will be a bit of time added to this query, but hoping it's minimal.

@emrysal please let me know if you envisioned this lookup happening a different way. Thanks!

AaronPresley avatar Feb 07 '23 17:02 AaronPresley