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: view team bookings #13591

Merged
merged 46 commits into from
Mar 12, 2024
Merged

Conversation

SomayChauhan
Copy link
Member

What does this PR do?

Fixes #13582

Copy link

vercel bot commented Feb 8, 2024

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

A member of the Team first needs to authorize it.

@github-actions github-actions bot added bookings area: bookings, availability, timezones, double booking foundation High priority Created by Linear-GitHub Sync teams area: teams, round robin, collective, managed event-types labels Feb 8, 2024
Copy link
Contributor

github-actions bot commented Feb 8, 2024

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

Copy link
Contributor

github-actions bot commented Feb 8, 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! 🙌

@Ryukemeister Ryukemeister requested a review from a team February 8, 2024 07:18
@Udit-takkar Udit-takkar self-requested a review February 8, 2024 08:53
role: {
in: ["ADMIN", "OWNER"],
},
},
Copy link
Contributor

@supalarry supalarry Feb 8, 2024

Choose a reason for hiding this comment

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

This fixes the issue, but:

As I understand a user can belong to only 1 organization (team), but what if this changes in future ? In such a case, I think code changes would allow:

  1. admin A invites Alice to team A and creates managed event for her
  2. admin B invites Alice to team B
  3. Alice gets a booking from managed event created by admin A
  4. Because admin B is a team member of Alice, I think he would see booking from team A

So I think this query is too wide and should be narrowed down unless I am missing something. What do you think?

Copy link
Member Author

Choose a reason for hiding this comment

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

hmmm.. 🤔,
you're right, both team admins can see bookings of each other if they have a common user

Copy link
Member Author

Choose a reason for hiding this comment

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

can't think of any to way to narrow down the query, i will let smarter people handle this one 😅

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe when Managed event is created we can pass admin id and connect it to users of event type. I think right now only the owner of event is connected to there. So we might need to adjust how Managed event type is created and then query it.

Copy link
Member Author

Choose a reason for hiding this comment

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

yup!, you are right, will have to try something hacky, can't think of any direct method

Copy link
Member Author

Choose a reason for hiding this comment

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

@supalarry how about now ?

Copy link
Contributor

Choose a reason for hiding this comment

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

@SomayChauhan just so I can follow - what part exactly in the new code guarantees that admin B would not see booking from team A compared to how it was before?

@keithwillcode keithwillcode added the community Created by Linear-GitHub Sync label Feb 8, 2024
@keithwillcode keithwillcode marked this pull request as draft February 8, 2024 11:00
@keithwillcode keithwillcode added this to the v3.8 milestone Feb 8, 2024
@SomayChauhan SomayChauhan marked this pull request as ready for review February 9, 2024 06:07
@SomayChauhan SomayChauhan marked this pull request as draft February 9, 2024 06:45
@SomayChauhan SomayChauhan marked this pull request as ready for review February 9, 2024 09:04
@SomayChauhan
Copy link
Member Author

LOOM

Copy link
Contributor

@keithwillcode keithwillcode left a comment

Choose a reason for hiding this comment

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

Automated tests need to be added to ensure this works properly and incorrect access isn’t given

@keithwillcode keithwillcode marked this pull request as draft February 9, 2024 21:24
@PeerRich
Copy link
Member

@SomayChauhan wanna write a test?

@SomayChauhan
Copy link
Member Author

Yes I'm working on it @PeerRich ,
Got caught up with some work, will push the tests soon

@keithwillcode keithwillcode marked this pull request as draft March 6, 2024 13:04
@SomayChauhan SomayChauhan marked this pull request as ready for review March 8, 2024 06:47
Copy link
Contributor

@Udit-takkar Udit-takkar left a comment

Choose a reason for hiding this comment

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

looks fine to me. will wait for @supalarry or keith before merging

@keithwillcode keithwillcode self-requested a review March 12, 2024 14:53
@keithwillcode keithwillcode dismissed supalarry’s stale review March 12, 2024 14:53

Requested changes have been made

@keithwillcode keithwillcode merged commit 4585199 into calcom:main Mar 12, 2024
29 of 37 checks passed
Copy link
Member

@zomars zomars left a comment

Choose a reason for hiding this comment

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

Thank you for your contribution 🙏 @SomayChauhan

Just as a postmortem.

The addition of this specific query it is causing the DB CPU to be at 100%. Causing connection issues in the whole app. We will have to revert this PR in order fix it.

My main guess is that this query is missing a select statement. Causing to query ALL data from the booking.

My other guess is that this Promise.all is reaching its limit. While it might indeed be "faster" to fetch these all at once. It is also true that this will be causing CPU spikes as we seen today in the v3.8.8 release.

Thanks again for the patience 🙏🏽

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 community Created by Linear-GitHub Sync foundation High priority Created by Linear-GitHub Sync 💰 Rewarded Rewarded bounties on Algora.io teams area: teams, round robin, collective, managed event-types
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[CAL-3089] View Bookings of Team
7 participants