Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Collective event types with seats - hosts count towards the seat count #14930

Merged

Conversation

Amit91848
Copy link
Contributor

@Amit91848 Amit91848 commented May 7, 2024

What does this PR do?

Fixes #14926

Before :

Screen.Recording.2024-05-08.at.2.36.14.PM.mov

After:

Screen.Recording.2024-05-08.at.2.37.05.PM.mov

Type of change

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

Mandatory Tasks

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

@graphite-app graphite-app bot requested a review from a team May 7, 2024 21:17
@graphite-app graphite-app bot added the community Created by Linear-GitHub Sync label May 7, 2024
Copy link

vercel bot commented May 7, 2024

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

A member of the Team first needs to authorize it.

Copy link
Contributor

github-actions bot commented May 7, 2024

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

@github-actions github-actions bot added seats area: seats, guest meetings, multiple people 🐛 bug Something isn't working labels May 7, 2024
Copy link

graphite-app bot commented May 7, 2024

Graphite Automations

"Add community label" took an action on this PR • (05/07/24)

1 label was added to this PR based on Keith Williams's automation.

"Add consumer team as reviewer" took an action on this PR • (05/07/24)

1 reviewer was added to this PR based on Keith Williams's automation.

Copy link
Contributor

github-actions bot commented May 7, 2024

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

@keithwillcode keithwillcode added this to the v4.1 milestone May 8, 2024
@github-actions github-actions bot added the Medium priority Created by Linear-GitHub Sync label May 13, 2024
@keithwillcode keithwillcode modified the milestones: v4.1, v4.2 May 15, 2024
Copy link
Contributor

@supalarry supalarry left a comment

Choose a reason for hiding this comment

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

Great work and thank your for the "Before" and "After" Looms - they are useful!

I have some refactors in mind:

dateFrom: Dayjs,
dateTo: Dayjs,
isTeamEvent?: boolean,
hosts?: string[]
Copy link
Contributor

Choose a reason for hiding this comment

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

_getCurrentSeats now takes in 5 parameters, which is a lot for a function. I propose combining eventTypeId, isTeamEvent and hosts into 1 eventType parameter:

eventType: Pick<EventType, "id" | "schedulingType" | "hosts">,
dateFrom: Dayjs,
dateTo: Dayjs

and then within _getCurrentSeats we access event type properties to check:

const isTeamEvent = eventType?.schedulingType !== null;
const hostEmails = eventType?.hosts.map((host) => host.user.email);

And to invoke function:

currentSeats = await getCurrentSeats(eventType, dateFrom, dateTo);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

eventType: Pick<EventType, "id" | "schedulingType" | "hosts">,
dateFrom: Dayjs,
dateTo: Dayjs

Screenshot 2024-05-16 at 4 38 19 PM

For some reason Pick doesn't work on EventType or User so had to hardcode the eventType

@@ -215,11 +258,13 @@ const _getUserAvailability = async function getUsersWorkingHoursLifeTheUniverseA
let eventType: EventType | null = initialData?.eventType || null;
if (!eventType && eventTypeId) eventType = await getEventType(eventTypeId);

const isTeamEvent = eventType?.schedulingType !== null;
Copy link
Contributor

Choose a reason for hiding this comment

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

In comment about "_getCurrentSeats now takes in 5 parameters" I suggest "const isTeamEvent" logic should be moved inside "_getCurrentSeats", but then I am also thinking:

I think it's better to be explicit about when something is a team event:

const isTeamEvent = eventType?.schedulingType === SchedulingType.COLLECTIVE  || eventType?.schedulingType === SchedulingType.ROUND_ROBIN || eventType?.schedulingType === SchedulingType.COLLECTIVE

My logic for this is that currently SchedulingType indeed shows only scheduling types of teams, but what if someone adds a SchedulingType that is non-team? Then this logic would potentially break.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We can also directly filter on hosts as only team events have hosts but that might change in the future so using hosts and schedulingType

@Amit91848 Amit91848 requested a review from supalarry May 16, 2024 12:00
Copy link
Contributor

@supalarry supalarry left a comment

Choose a reason for hiding this comment

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

Great work Amit! It's nice to have this fixed.

Tested with collective and round robin and it works! : )

@CarinaWolli CarinaWolli enabled auto-merge (squash) May 17, 2024 13:28
@CarinaWolli CarinaWolli merged commit 9c64e8d into calcom:main May 17, 2024
32 of 39 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Something isn't working community Created by Linear-GitHub Sync Medium priority Created by Linear-GitHub Sync seats area: seats, guest meetings, multiple people
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[CAL-3658] Collective event types with seats - hosts count towards the seat count
6 participants