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

[CAL-736] Collective events are ignored from getBusyTimes booking query

Open emrysal opened this issue 2 years ago β€’ 1 comments

Issue Summary

In getBusyTimes.ts - conflicting bookings are found based on userId, this does not work on a Collective event as there is no single user assigned, so other event types remain bookable when there is no calendar connected.

const busyTimes: EventBusyDetails[] = await prisma.booking
    .findMany({
      where: {
        userId,
        startTime: { gte: new Date(startTime) },
        endTime: { lte: new Date(endTime) },
        status: {
          in: [BookingStatus.ACCEPTED],
        },
      },
      select: {
        id: true,
        startTime: true,
        endTime: true,
        title: true,
        eventType: {
          select: {
            id: true,
            afterEventBuffer: true,
            beforeEventBuffer: true,
          },
        },
      },
    })

From SyncLinear.com | CAL-736

emrysal avatar Jan 10 '23 16:01 emrysal

@emrysal do you wanna look into it? you have some experience with getBusyTimes

PeerRich avatar Jan 26 '23 12:01 PeerRich

@PeerRich I'm investigating this one

AaronPresley avatar Feb 01 '23 21:02 AaronPresley

nice!

PeerRich avatar Feb 01 '23 21:02 PeerRich

feel free to book cal.com/emrysal if you have questions

PeerRich avatar Feb 01 '23 21:02 PeerRich

@PeerRich @emrysal would you mind guiding me on how to create a Collective event? I've done the following:

From there I see a list of the team's individual members, which I gather does not create a Collective event, but an event for that specific user. I also tried booking an event with multiple attendees, which didn't reproduce the bug either.

What's the best way to create a Collective event?

Thanks πŸ™

AaronPresley avatar Feb 01 '23 22:02 AaronPresley

From the event type page you can create a team event type, in which you can choose Collective or Round Robin.

image

Also you can use the [email protected] account

emrysal avatar Feb 01 '23 22:02 emrysal

@emrysal Sorry for my dumbness here, but I'm still struggling to recreate this issue. I've done the following:

  • Completely reset my local db by running yarn db-nuke from within packages/prisma
  • Booted the app locally with yarn dx
  • Logged into [email protected]
  • Created a new Event Type for Team Pro the individual user (the seeded data doesn't have this by default)
  • Confirmed in the new Event Type that Team Pro is shown as available for a given time slot (ex: Feb 6 @ 8am)
  • Edited the Seeded Team's "Collective Seeded Team Event" > Assignment > added Team Pro as the only team member > Save
  • Opened the public url for "Collective Seeded Team Event" and scheduled an event for Feb 6 @ 8am
  • Confirmed this new event shows up under Bookings
  • Opened the Team Pro user public URL, and the Feb 6 @ 8am time slot is no longer available

Can you help me understand what I'm missing? I'll schedule some time to discuss, but your next availability isn't until tomorrow (my time) so I'd love to be unblocked sooner than that πŸ™

Maybe @PeerRich you could confirm whether this bug is still present, or I'm just misunderstanding the best way to recreate it?

AaronPresley avatar Feb 02 '23 18:02 AaronPresley

this could be one of those hard to debug calendar bugs. welcome to Cal.com! 🀣

PeerRich avatar Feb 02 '23 19:02 PeerRich

@emrysal sorry we weren't able to meet, feel free to reschedule for another time if you like.

@PeerRich I'm going to move on from this ticket for now until someone can give me guidance on reliably reproducing it πŸ™

AaronPresley avatar Feb 03 '23 17:02 AaronPresley

@AaronPresley apologies, I never got the event added to my calendar (even though my google integration seems fine) - re-connected google so I don't miss bookings going forward.

I'll reschedule.

emrysal avatar Feb 03 '23 17:02 emrysal

@emrysal no worries! I noticed you booked the meeting for Feb 13, 10 days from now. Was that intentional? I'm also available Monday the 6th. Otherwise see you on the 13th πŸ‘

AaronPresley avatar Feb 03 '23 17:02 AaronPresley

It wasn't; thanks for the heads up

One thing of note I can think of right now that may cause your collective event to show up is if you are the owner, it won't show up if you are not, have you tried the collective event as a non-owner?

  • Create the event type as teampro
  • Assign to the collective event [email protected]
  • Make the booking as any external user, not [email protected]
  • See if the collective event is marked as busy

emrysal avatar Feb 03 '23 17:02 emrysal

@emrysal thanks for the chat today, and the above edit. I'm now able to recreate the bug locally πŸ™Œ

AaronPresley avatar Feb 06 '23 17:02 AaronPresley