Skip to content

feat: insights orgs [CAL-1888]#9551

Merged
PeerRich merged 21 commits into
mainfrom
feat-insights-orgs
Jun 29, 2023
Merged

feat: insights orgs [CAL-1888]#9551
PeerRich merged 21 commits into
mainfrom
feat-insights-orgs

Conversation

@alannnc
Copy link
Copy Markdown
Contributor

@alannnc alannnc commented Jun 16, 2023

What does this PR do?

  • Handles insights if user logged in is owner/admin inside team org.

Fixes # (issue)
Fixes #9360

https://www.loom.com/share/d149cc7b8dfd436487f404d472c1840c

Type of change

  • New feature (non-breaking change which adds functionality)

How should this be tested?

  • Start with a new fresh db.
  • Setup an org from /settings/organizations/new.
  • In your terminal navigate to your packages/prisma folder and run command yarn seed-insights.
  • Modify newly created insights team to be child of team org.
  • Navigate to your insights page as org owner/admin and use all the features.

Mandatory Tasks

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

Checklist

  • I haven't added tests that prove my fix is effective or that my feature works

@vercel
Copy link
Copy Markdown

vercel Bot commented Jun 16, 2023

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

Name Status Preview Comments Updated (UTC)
api ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 29, 2023 4:58pm
cal ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 29, 2023 4:58pm
ui ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 29, 2023 4:58pm
web-staging ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 29, 2023 4:58pm

const { t } = useLocale();
const { filter } = useFilterContext();
const { dateRange, selectedMemberUserId } = filter;
const { dateRange, selectedMemberUserId, isOrg } = filter;
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

new prop in UI that tell us if Team option selected is the team that is parent of other teams.

userId: null,
teamId: null,
isOrg: false,
});
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added this so I can save initialConfig and reinstate it when using clear filters button.

const userId =
filter?.[0] === "user" ? selectedMemberUserId : selectedUserId ? selectedUserId : undefined;
const eventTypeId = filter?.[0] === "event-type" ? selectedEventTypeId : undefined;
const memberUserId = filter?.[0] === "user" ? selectedMemberUserId : undefined;
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Was missing some clean up here when running clean filters action

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 16, 2023

📦 Next.js Bundle Analysis for @calcom/web

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

One Page Changed Size

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

Page Size (compressed) First Load % of Budget (350 KB)
/insights 479.77 KB 633.13 KB 180.90% (🟡 +2.42%)
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.

@deploysentinel
Copy link
Copy Markdown

deploysentinel Bot commented Jun 16, 2023

Current Playwright Test Results Summary

✅ 124 Passing - ⚠️ 5 Flaky

Run may still be in progress, this comment will be updated as current testing workflow or job completes...

(Last updated on 06/29/2023 05:00:43pm UTC)

Run Details

Running Workflow PR Update on Github Actions

Commit: 1d6aca3

Started: 06/29/2023 04:58:35pm UTC

⚠️ Flakes

📄   packages/app-store/routing-forms/playwright/tests/basic.e2e.ts • 1 Flake

Test Case Results

Test Case Last 7 days Failures Last 7 days Flakes
Routing Forms Seeded Routing Form Routing Link should validate fields
Retry 1Initial Attempt
0% (0) 0 / 166 runs
failed over last 7 days
2.41% (4) 4 / 166 runs
flaked over last 7 days

📄   packages/embeds/embed-core/playwright/tests/action-based.e2e.ts • 2 Flakes

Top 1 Common Error Messages

null

2 Test Cases Affected

Test Case Results

Test Case Last 7 days Failures Last 7 days Flakes
Popup Tests -- new-booker should be able to reschedule
Retry 1Initial Attempt
12.86% (9) 9 / 70 runs
failed over last 7 days
21.43% (15) 15 / 70 runs
flaked over last 7 days
Popup Tests -- old-booker should be able to reschedule
Retry 1Initial Attempt
2.86% (2) 2 / 70 runs
failed over last 7 days
11.43% (8) 8 / 70 runs
flaked over last 7 days

📄   apps/web/playwright/reschedule.e2e.ts • 1 Flake

Test Case Results

Test Case Last 7 days Failures Last 7 days Flakes
Reschedule Tests -- new-booker Paid rescheduling should go to success page
Retry 1Initial Attempt
0.40% (1) 1 / 249 run
failed over last 7 days
2.01% (5) 5 / 249 runs
flaked over last 7 days

📄   apps/web/playwright/booking-seats.e2e.ts • 1 Flake

Test Case Results

Test Case Last 7 days Failures Last 7 days Flakes
Booking with Seats -- old-booker Attendees can cancel a seated event time slot
Retry 1Initial Attempt
0% (0) 0 / 254 runs
failed over last 7 days
2.36% (6) 6 / 254 runs
flaked over last 7 days

View Detailed Build Results



const UserBelongsToTeamInput = z.object({
teamId: z.coerce.number().optional().nullable(),
isOrg: z.boolean().optional(),
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Most important changes where in this file and github just hides it

...ctx,
user: {
...ctx.user,
isOwnerAdminOfParentTeam: true,
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

If no direct membership is found, we then look for parent teams and look if user session is admin/owner.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Then we pass down ctx a new prop that user is validated and if isOrg is passed in input we should allow user get child teams data.

select: {
id: true,
},
});
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Getting teams from org

in: teamsFromOrg.map((t) => t.id),
},
};
const usersFromOrg = await ctx.prisma.membership.findMany({
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Then we convert those teams to users ids

where: eventTypeWhereConditional,
});

default:
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Changed from switch to if conditional


if (teamId) {
if (isOrg && ctx.user.isOwnerAdminOfParentTeam) {
const teamsFromOrg = await ctx.prisma.team.findMany({
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Same is done across actions in insights methods

@alannnc alannnc marked this pull request as ready for review June 16, 2023 00:44
@alannnc alannnc changed the title Feat: insights orgs feat: insights orgs Jun 16, 2023
@alannnc alannnc requested review from leog, roae and zomars June 16, 2023 00:45
@CarinaWolli CarinaWolli added the organizations area: organizations, orgs label Jun 16, 2023
@leog leog changed the title feat: insights orgs feat: insights orgs [CAL-1888] Jun 16, 2023
@linear
Copy link
Copy Markdown

linear Bot commented Jun 16, 2023

ericrommel
ericrommel previously approved these changes Jun 28, 2023
Copy link
Copy Markdown
Contributor

@ericrommel ericrommel left a comment

Choose a reason for hiding this comment

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

LGTM. Just need to check the failed builds to have this PR all green.

@PeerRich PeerRich merged commit d180e14 into main Jun 29, 2023
@PeerRich PeerRich deleted the feat-insights-orgs branch June 29, 2023 17:03
@PeerRich PeerRich added the core area: core, team members only label Jul 24, 2023
fritterhoff pushed a commit to hm-edu/cal.com that referenced this pull request Jul 25, 2023
* initial commit

* fixes on data returned

* mobile style fixes

* Update on styles and dates not being shown on graphics

* feat: update insights filters UI (calcom#9756)

* feat: update insights filters UI

Signed-off-by: Udit Takkar <udit.07814802719@cse.mait.ac.in>

* Fixes for filters with new UI

* fix initialConfig lost while clearing filters

* Add single user conditional for first render

---------

Signed-off-by: Udit Takkar <udit.07814802719@cse.mait.ac.in>
Co-authored-by: Alan <alannnc@gmail.com>

---------

Signed-off-by: Udit Takkar <udit.07814802719@cse.mait.ac.in>
Co-authored-by: Efraín Rochín <roae.85@gmail.com>
Co-authored-by: Udit Takkar <53316345+Udit-takkar@users.noreply.github.com>
Co-authored-by: Peer Richelsen <peeroke@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core area: core, team members only High priority Created by Linear-GitHub Sync organizations area: organizations, orgs

Projects

No open projects
Status: No status

Development

Successfully merging this pull request may close these issues.

[CAL-1874] Insights filters

7 participants