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

chore: sort calendar crendentials in event manager #15448

Conversation

Shaik-Sirajuddin
Copy link
Contributor

What does this PR do?

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
  • I have added or modified automated tests that prove my fix is effective or that my feature works (PRs might be rejected if logical changes are not properly tested)

@graphite-app graphite-app bot requested a review from a team June 16, 2024 15:30
@graphite-app graphite-app bot added the community Created by Linear-GitHub Sync label Jun 16, 2024
Copy link

vercel bot commented Jun 16, 2024

Someone 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 calendar-apps area: calendar, google calendar, outlook, lark, microsoft 365, apple calendar foundation High priority Created by Linear-GitHub Sync 🐛 bug Something isn't working labels Jun 16, 2024
@dosubot dosubot bot added the core area: core, team members only label Jun 16, 2024
@dosubot dosubot bot added this to the v4.2 milestone Jun 16, 2024
Copy link

graphite-app bot commented Jun 16, 2024

Graphite Automations

"Add community label" took an action on this PR • (06/16/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 • (06/16/24)

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

@keithwillcode keithwillcode modified the milestones: v4.2, v4.3 Jun 17, 2024
@dosubot dosubot bot modified the milestone: v4.3 Jun 17, 2024
@supalarry supalarry self-requested a review June 27, 2024 14:27
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.

@hariombalhara I am confused - in the linked issue #11671 you wrote:

we erroneously consider that credential as the first one, instead of the first added one actually.

but by sorting it by DESC using:

.sort((a, b) => {
    return b.id - a.id;
});

we have last added calendar as the default fallback one, but the function for falling back is called fallbackToFirstConnectedCalendar.

So - do we want by default to fallback to the first connected calendar, or to the latest one?

If first connected, we need to sort in ASCENDING order by id. I think this makes most sense - fallback to first connected.

If by latest one, we need to rename fallbackToFirstConnectedCalendar to fallbackToLastConnectedCalendar.

@hariombalhara
Copy link
Member

hariombalhara commented Jun 28, 2024

@supalarry Yeah the statement isn't correct. I meant we need to have the latest added one consistently which would be the first one if we do sort in descending.

The same way we do for videoCredentials
image

Also, fallbackToFirstConnectedCalendar should actually be fallbackToFirstInTheList because that is what it does.

Comment on lines 107 to 109
.sort((a, b) => {
return b.id - a.id;
});
Copy link
Member

Choose a reason for hiding this comment

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

how about we name this arrow function, latestFirst and reuse it below as well.
Makes the code more readable

Copy link
Contributor

Choose a reason for hiding this comment

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

Do you mean oldestFirst as we are sorting in ascending order

Copy link
Member

Choose a reason for hiding this comment

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

I think we are sorting in descending order only, unless I am misunderstanding

image

Copy link
Member

@hariombalhara hariombalhara left a comment

Choose a reason for hiding this comment

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

Thanks @Shaik-Sirajuddin !!
I left a quick to implement suggestion otherwise it's good.

Udit-takkar
Udit-takkar previously approved these changes Jul 5, 2024
@Shaik-Sirajuddin
Copy link
Contributor Author

Shaik-Sirajuddin commented Jul 9, 2024

Thanks @Shaik-Sirajuddin !! I left a quick to implement suggestion otherwise it's good.

Updated function names as suggested
PTAL @hariombalhara , @Udit-takkar

Variable name change
Copy link
Contributor

📦 Next.js Bundle Analysis for @calcom/web

This analysis was generated by the Next.js Bundle Analysis action. 🤖

Eighty-one Pages Changed Size

The following pages changed size from the code in this PR compared to its base branch:

Page Size (compressed) First Load % of Budget (350 KB)
/apps 278.92 KB 506.54 KB 144.73% (🟢 -1.51%)
/apps/[slug] 296.49 KB 524.1 KB 149.74% (🟢 -1.51%)
/apps/[slug]/[...pages] 588.59 KB 816.21 KB 233.20% (🟢 -1.16%)
/apps/categories 256.24 KB 483.86 KB 138.25% (🟢 -1.23%)
/apps/categories/[category] 261.05 KB 488.66 KB 139.62% (🟢 -1.50%)
/apps/installation/[[...step]] 468.97 KB 696.59 KB 199.02% (🔴 +86.09%)
/apps/installed/[category] 278.19 KB 505.81 KB 144.52% (🟢 -1.83%)
/auth/saml-idp 12.22 KB 239.84 KB 68.53% (🟢 -20.80%)
/auth/setup 150.97 KB 378.59 KB 108.17% (🟡 +0.26%)
/availability 426.14 KB 653.76 KB 186.79% (🟢 -1.79%)
/availability/[schedule] 410.56 KB 638.18 KB 182.34% (🟢 -1.65%)
/bookings/[status] 326.17 KB 553.79 KB 158.23% (🟢 -1.16%)
/enterprise 256.3 KB 483.91 KB 138.26% (🟢 -1.23%)
/event-types 561.25 KB 788.87 KB 225.39% (🟢 -1.17%)
/event-types/[type] 437.8 KB 665.42 KB 190.12% (🟢 -1.06%)
/getting-started/[[...step]] 409.86 KB 637.47 KB 182.14% (🟢 -0.22%)
/insights 474.65 KB 702.27 KB 200.65% (🟢 -1.68%)
/more 255.8 KB 483.42 KB 138.12% (🟢 -1.23%)
/settings/admin 262.24 KB 489.86 KB 139.96% (🟢 -1.22%)
/settings/admin/apps 275.48 KB 503.1 KB 143.74% (🟢 -1.24%)
/settings/admin/apps/[category] 275.47 KB 503.08 KB 143.74% (🟢 -1.25%)
/settings/admin/flags 265.96 KB 493.58 KB 141.02% (🟢 -1.24%)
/settings/admin/impersonation 262.63 KB 490.25 KB 140.07% (🟢 -1.21%)
/settings/admin/lockedSMS 283.73 KB 511.34 KB 146.10% (🟢 -1.19%)
/settings/admin/oAuth 274.24 KB 501.85 KB 143.39% (🟢 -1.24%)
/settings/admin/orgMigrations/_OrgMigrationLayout 251.17 KB 478.79 KB 136.80% (🟢 -1.22%)
/settings/admin/orgMigrations/moveTeamToOrg 300.91 KB 528.52 KB 151.01% (🟢 -1.20%)
/settings/admin/orgMigrations/moveUserToOrg 320.74 KB 548.35 KB 156.67% (🟢 -1.17%)
/settings/admin/orgMigrations/removeTeamFromOrg 300.67 KB 528.29 KB 150.94% (🟢 -1.20%)
/settings/admin/orgMigrations/removeUserFromOrg 300.68 KB 528.3 KB 150.94% (🟢 -1.20%)
/settings/admin/organizations 264.13 KB 491.74 KB 140.50% (🟢 -1.22%)
/settings/admin/organizations/[id]/edit 262.79 KB 490.41 KB 140.12% (🟢 -1.22%)
/settings/admin/users 264.9 KB 492.51 KB 140.72% (🟢 -1.22%)
/settings/admin/users/[id]/edit 393.96 KB 621.57 KB 177.59% (🟢 -1.22%)
/settings/admin/users/add 393.62 KB 621.24 KB 177.50% (🟢 -1.22%)
/settings/billing 262.45 KB 490.06 KB 140.02% (🟢 -1.22%)
/settings/developer/api-keys 266.73 KB 494.35 KB 141.24% (🟢 -1.24%)
/settings/developer/webhooks 266.91 KB 494.52 KB 141.29% (🟢 -1.24%)
/settings/developer/webhooks/[id] 267.89 KB 495.5 KB 141.57% (🟢 -1.23%)
/settings/developer/webhooks/new 267.91 KB 495.53 KB 141.58% (🟢 -1.23%)
/settings/my-account/appearance 314.33 KB 541.95 KB 154.84% (🟢 -1.53%)
/settings/my-account/calendars 274.21 KB 501.83 KB 143.38% (🟢 -1.15%)
/settings/my-account/conferencing 272.2 KB 499.82 KB 142.80% (🟢 -1.98%)
/settings/my-account/general 377.85 KB 605.46 KB 172.99% (🟢 -1.24%)
/settings/my-account/out-of-office 267.37 KB 494.99 KB 141.42% (🟢 -1.24%)
/settings/my-account/profile 410.28 KB 637.9 KB 182.26% (🟢 -1.24%)
/settings/organizations/[id]/about 159.66 KB 387.27 KB 110.65% (🟡 +0.47%)
/settings/organizations/[id]/add-teams 159.65 KB 387.27 KB 110.65% (🟡 +0.47%)
/settings/organizations/admin-api 262.4 KB 490.02 KB 140.00% (🟢 -1.21%)
/settings/organizations/appearance 122.34 KB 349.96 KB 99.99% (🟢 -48.02%)
/settings/organizations/billing 262.48 KB 490.1 KB 140.03% (🟢 -1.22%)
/settings/organizations/dsync 295.1 KB 522.72 KB 149.35% (🟢 -1.22%)
/settings/organizations/general 350.69 KB 578.31 KB 165.23% (🟢 -1.24%)
/settings/organizations/members 400.51 KB 628.13 KB 179.46% (🟢 -1.61%)
/settings/organizations/new 159.66 KB 387.28 KB 110.65% (🟡 +0.47%)
/settings/organizations/privacy 267.89 KB 495.51 KB 141.57% (🟢 -1.24%)
/settings/organizations/profile 415.16 KB 642.78 KB 183.65% (🟡 +2.29%)
/settings/organizations/sso 273.07 KB 500.69 KB 143.05% (🟢 -1.21%)
/settings/organizations/teams/other 263.31 KB 490.93 KB 140.26% (🟢 -1.21%)
/settings/organizations/teams/other/[id]/appearance 275.11 KB 502.73 KB 143.64% (🟢 -1.20%)
/settings/organizations/teams/other/[id]/members 269.8 KB 497.42 KB 142.12% (🟢 -1.25%)
/settings/organizations/teams/other/[id]/profile 473.52 KB 701.14 KB 200.32% (🟢 -1.23%)
/settings/platform 260.9 KB 488.52 KB 139.58% (🟢 -1.23%)
/settings/platform/new 120.67 KB 348.29 KB 99.51% (🟡 +0.51%)
/settings/platform/oauth-clients/[clientId]/edit 259.21 KB 486.83 KB 139.09% (🟢 -1.22%)
/settings/platform/oauth-clients/create 258.35 KB 485.97 KB 138.85% (🟢 -1.23%)
/settings/security/impersonation 267.55 KB 495.17 KB 141.48% (🟢 -1.25%)
/settings/security/password 305.7 KB 533.32 KB 152.38% (🟢 -1.23%)
/settings/security/sso 272.52 KB 500.14 KB 142.90% (🟢 -1.22%)
/settings/security/two-factor-auth 271.03 KB 498.65 KB 142.47% (🟢 -1.24%)
/settings/teams 261.98 KB 489.6 KB 139.88% (🟢 -1.21%)
/settings/teams/[id]/appearance 275.1 KB 502.72 KB 143.63% (🟢 -1.19%)
/settings/teams/[id]/billing 262.48 KB 490.1 KB 140.03% (🟢 -1.22%)
/settings/teams/[id]/members 379.92 KB 607.54 KB 173.58% (🟢 -1.24%)
/settings/teams/[id]/profile 474.3 KB 701.92 KB 200.55% (🟢 -1.24%)
/settings/teams/new 193 KB 420.62 KB 120.18% (🟢 -1.83%)
/teams 256.03 KB 483.65 KB 138.18% (🟢 -1.22%)
/upgrade 256.15 KB 483.77 KB 138.22% (🟢 -1.23%)
/video/[uid] 291.18 KB 518.8 KB 148.23% (🟢 -0.18%)
/workflows 288.06 KB 515.67 KB 147.34% (🟢 -1.18%)
/workflows/[workflow] 414.6 KB 642.22 KB 183.49% (🟢 -1.44%)
Details

Only the gzipped size is provided here based on an expert tip.

First Load is the size of the global bundle plus the bundle for the individual page. If a user were to show up to your website and land on a given page, the first load size represents the amount of javascript that user would need to download. If next/link is used, subsequent page loads would only need to download that page's bundle (the number in the "Size" column), since the global bundle has already been downloaded.

Any third party scripts you have added directly to your app using the <script> tag are not accounted for in this analysis

The "Budget %" column shows what percentage of your performance budget the First Load total takes up. For example, if your budget was 100kb, and a given page's first load size was 10kb, it would be 10% of your budget. You can also see how much this has increased or decreased compared to the base branch of your PR. If this percentage has increased by 20% or more, there will be a red status indicator applied, indicating that special attention should be given to this. If you see "+/- <0.01%" it means that there was a change in bundle size, but it is a trivial enough amount that it can be ignored.

@hariombalhara hariombalhara merged commit 58540af into calcom:main Jul 10, 2024
41 of 49 checks passed
verstratenbram added a commit to verstratenbram/cal.com that referenced this pull request Jul 16, 2024
* commit '0dd3b2562458522ad002b4ea967e2b10855a4ab6': (130 commits)
  chore: v4.2.5 (calcom#15735)
  fix: api v2 unit tests  (calcom#15733)
  fix: event type back button (calcom#15722)
  fix: remove console.log and tsignore apiv2 (calcom#15732)
  fix: api-v2 controllers e2e tests (calcom#15724)
  fix: Text in Embed Code  Visibility Fixed (calcom#15711)
  chore: sort calendar crendentials in event manager (calcom#15448)
  chore: cache org guard and fix roles guard apiv2 (calcom#15719)
  Revert "fix: Autodetection of time zone only updated default time zone (calcom#15392)" (calcom#15720)
  feat: add POST end point to mark calls as no-shows (calcom#15690)
  chore: add i18n to atoms (calcom#15698)
  fix: set conferencing apps as default (calcom#15376)
  fix: disable google-meet in user onboarding if google-calendar is not installed (calcom#15702)
  fix: Rescheduling email when there is broken calendar integration (calcom#15669)
  chore: v4.2.4 (calcom#15703)
  fix: 404s becoming 500s (calcom#15696)
  fix: delete reserved slot on booker unmount (calcom#15700)
  chore: add caching apiv2 roles guard (calcom#15694)
  refactor: handleNewBooking calcom#3 (calcom#15612)
  fix: incorrect booking seats full error on collective seated event (calcom#15602)
  ...

# Conflicts:
#	packages/emails/templates/attendee-request-email.ts
#	packages/emails/templates/attendee-was-requested-to-reschedule-email.ts
#	packages/emails/templates/organizer-cancelled-email.ts
#	packages/emails/templates/organizer-location-change-email.ts
#	packages/emails/templates/organizer-payment-refund-failed-email.ts
#	packages/emails/templates/organizer-request-email.ts
#	packages/emails/templates/organizer-request-reminder-email.ts
#	packages/emails/templates/organizer-requested-to-reschedule-email.ts
#	packages/emails/templates/organizer-rescheduled-email.ts
#	packages/emails/templates/organizer-scheduled-email.ts
p6l-richard pushed a commit to p6l-richard/cal.com-fork that referenced this pull request Jul 22, 2024
* chore_sort_calendar_credentials_in_desc_for_reliability

* chore: create reusable function

* refactor: rename functions

* Update EventManager.ts

Variable name change

---------

Co-authored-by: Shaik-Sirajuddin <sirajudddinshaik30@gmail.com>
Co-authored-by: Keith Williams <keithwillcode@gmail.com>
Co-authored-by: Udit Takkar <53316345+Udit-takkar@users.noreply.github.com>
Co-authored-by: Udit Takkar <udit222001@gmail.com>
Co-authored-by: Hariom Balhara <hariombalhara@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Something isn't working calendar-apps area: calendar, google calendar, outlook, lark, microsoft 365, apple calendar community Created by Linear-GitHub Sync core area: core, team members only foundation High priority Created by Linear-GitHub Sync ready-for-e2e
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[CAL-2569] Fallback of using the first connected calendar isn’t reliable
5 participants