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

refactor: loadUsers and move to separate file #15532

Merged
merged 8 commits into from
Jun 25, 2024
Merged

Conversation

Udit-takkar
Copy link
Contributor

@Udit-takkar Udit-takkar commented Jun 21, 2024

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)
  • N/A I have added a Docs issue here if this PR makes changes that would require a documentation change
  • N/A 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 21, 2024 20:53
@keithwillcode keithwillcode added consumer core area: core, team members only labels Jun 21, 2024
@dosubot dosubot bot added bookings area: bookings, availability, timezones, double booking 💻 refactor labels Jun 21, 2024
Copy link

vercel bot commented Jun 21, 2024

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

Name Status Preview Comments Updated (UTC)
ai ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 25, 2024 6:48am
2 Ignored Deployments
Name Status Preview Comments Updated (UTC)
cal ⬜️ Ignored (Inspect) Visit Preview Jun 25, 2024 6:48am
calcom-web-canary ⬜️ Ignored (Inspect) Visit Preview Jun 25, 2024 6:48am

Copy link

graphite-app bot commented Jun 21, 2024

Graphite Automations

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

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

Comment on lines 23 to 24
? await loadUsersByEventType(eventType)
: await loadDynamicUsers(dynamicUserList, req);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

separated the logic in these two functions

* This method is mostly same as the one in UserRepository but it includes a lot more relations which are specific requirement here
* TODO: Figure out how to keep it in UserRepository and use it here
*/
export const findUsersByUsername = async ({
Copy link
Contributor Author

Choose a reason for hiding this comment

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

no change in the code here.

Copy link
Contributor

Choose a reason for hiding this comment

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

It looks like this logic is already in the UserRepository. Can we delete this duplicate code?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this function returns few more fields(credentials and metadata) than the static function in UserRepository.

Copy link
Contributor

github-actions bot commented Jun 22, 2024

📦 Next.js Bundle Analysis for @calcom/web

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

Eleven 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/[slug]/[...pages] 593.33 KB 821.02 KB 234.58% (🟡 +0.19%)
/auth/saml-idp 12.22 KB 239.92 KB 68.55% (🟢 -20.80%)
/event-types 566.35 KB 794.05 KB 226.87% (🟡 +0.28%)
/settings/admin/lockedSMS/UsersTable 79.88 KB 307.58 KB 87.88% (🟢 -0.17%)
/settings/admin/lockedSMS/lockedSMSView 119.37 KB 347.06 KB 99.16% (🟢 -0.20%)
/settings/admin/oAuth/oAuthView 95.43 KB 323.13 KB 92.32% (🟢 -0.19%)
/settings/organizations/[id]/about 159.59 KB 387.29 KB 110.65% (🟡 +0.46%)
/settings/organizations/[id]/add-teams 159.58 KB 387.28 KB 110.65% (🟡 +0.45%)
/settings/organizations/new 159.6 KB 387.29 KB 110.66% (🟡 +0.45%)
/settings/platform/new 120.65 KB 348.34 KB 99.53% (🟡 +0.50%)
/video/[uid] 290.75 KB 518.44 KB 148.13% (🟢 -0.31%)
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.

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.

@Udit-takkar Left a few suggestions for code improvement

};

const loadDynamicUsers = async (dynamicUserList: string[], currentOrgDomain: string | null) => {
if (!Array.isArray(dynamicUserList) || dynamicUserList.length === 0) {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
if (!Array.isArray(dynamicUserList) || dynamicUserList.length === 0) {
if (dynamicUserList.length === 0) {


const loadDynamicUsers = async (dynamicUserList: string[], currentOrgDomain: string | null) => {
if (!Array.isArray(dynamicUserList) || dynamicUserList.length === 0) {
throw new Error("dynamicUserList is not properly defined or empty.");
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
throw new Error("dynamicUserList is not properly defined or empty.");
throw new Error("dynamicUserList is empty.");

@hariombalhara hariombalhara added this pull request to the merge queue Jun 25, 2024
Merged via the queue into main with commit 86fc516 Jun 25, 2024
34 of 39 checks passed
@hariombalhara hariombalhara deleted the refactor/load-users branch June 25, 2024 07:17
@Udit-takkar Udit-takkar mentioned this pull request Jul 10, 2024
3 tasks
p6l-richard pushed a commit to p6l-richard/cal.com-fork that referenced this pull request Jul 22, 2024
* refactor: loadUsers and move to separate file

* fix: improvement

---------

Co-authored-by: Keith Williams <keithwillcode@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
bookings area: bookings, availability, timezones, double booking consumer core area: core, team members only ready-for-e2e 💻 refactor
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants