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: RR Skip get contact owner username server side #16336

Closed
wants to merge 16 commits into from

Conversation

joeauyeung
Copy link
Contributor

@joeauyeung joeauyeung commented Aug 23, 2024

What does this PR do?

Previously we would rely on the bookingForm stat to get the CRM contact owner's availability if an email was passed in the URL query. This was causing the getSchedule hook to double fire on initial page load.

This PR aims to get the CRM contact owner server side and pass that use name to getSchedule as a prop so it only has to fetch that single user's availability.

https://www.loom.com/share/29ae904eceed4aa5aced449a639d64a1?sid=3cad71bc-1def-49fc-84b2-e06fdf162b40

Mandatory Tasks (DO NOT REMOVE)

  • I have self-reviewed the code (A decent size PR without self-review might be rejected).
  • I have added a Docs issue here if this PR makes changes that would require a documentation change. If N/A, write N/A here and check the checkbox.
  • I confirm automated tests are in place that prove my fix is effective or that my feature works.

How should this be tested?

  • Connect Salesforce and enable round robin skipping based on contact owner
  • Go to the booking page and pass a Salesforce contact email as email=... in the URL query
    • Ensure that the contact owner is a part of your Salesforce instance
  • The availability should only be queried for the contact owner

@graphite-app graphite-app bot requested a review from a team August 23, 2024 17:56
@keithwillcode keithwillcode added consumer core area: core, team members only labels Aug 23, 2024
@dosubot dosubot bot added booking-page area: booking page, public booking page, booker crm-apps area: crm apps, salesforce, hubspot, close.com, sendgrid 🐛 bug Something isn't working labels Aug 23, 2024
Copy link

graphite-app bot commented Aug 23, 2024

Graphite Automations

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

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

rescheduleUid,
duration: queryDuration,
isInstantMeeting: queryIsInstantMeeting,
email,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Read the attendee's email server side from the URL query.

@@ -75,6 +82,28 @@ export const getServerSideProps = async (context: GetServerSidePropsContext) =>
fromRedirectOfNonOrgLink: context.query.orgRedirection === "true",
});

const roundRobinUsernamePool = [];
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm picturing in the future there might be use cases where we only want a subset of round robin users for users to book. Ex. based on a specific attribute? @sean-brydon

const crmContactOwner = await getCRMContactOwnerForRRLeadSkip(email, eventData.id);

if (crmContactOwner) {
const ownerUsername = await prisma.user.findUnique({
Copy link
Contributor Author

Choose a reason for hiding this comment

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

In Salesforce only the email is stored and the public event endpoint doesn't return emails. For privacy I didn't want to add the users emails to the public endpoint.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Abstracted from slots/util.ts

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Need to pass the organizer email when creating new contacts so they belong to the organizer in the CRM.

@@ -201,6 +198,7 @@ export async function getEventType(
},
},
hosts: {
...(roundRobinUsernamePool ? { where: { user: { username: { in: roundRobinUsernamePool } } } } : {}),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

If roundRobinUsernamePool is passed then when fetching the event type we should also only fetch the hosts that belong in that pool of usernames. This way we don't need to fetch the availability of all the hosts.

Copy link

vercel bot commented Aug 23, 2024

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

2 Skipped Deployments
Name Status Preview Comments Updated (UTC)
cal ⬜️ Ignored (Inspect) Visit Preview Aug 27, 2024 3:23am
calcom-web-canary ⬜️ Ignored (Inspect) Visit Preview Aug 27, 2024 3:23am

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.

@joeauyeung type checks are failing

@joeauyeung
Copy link
Contributor Author

Closing in favour of a simpler solution in #16367

@joeauyeung joeauyeung closed this Aug 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
booking-page area: booking page, public booking page, booker 🐛 bug Something isn't working consumer core area: core, team members only crm-apps area: crm apps, salesforce, hubspot, close.com, sendgrid
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants