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: '/slots' endpoint API fixes #12693

Merged
merged 5 commits into from
Dec 6, 2023
Merged

fix: '/slots' endpoint API fixes #12693

merged 5 commits into from
Dec 6, 2023

Conversation

alishaz-polymath
Copy link
Member

@alishaz-polymath alishaz-polymath commented Dec 6, 2023

What does this PR do?

Fixes the slots endpoint issues:

  • usernameList requiring more than 1 usernameList entries (event for single user) and thus ignoring the eventTypeSlug and instead picking dynamic event type all the time
  • timeZone handling to return timeZone specific slots instead of slots in UTC which is currently happening. We need to do this on the API front alone so as to not disrupt the slot fetching flow in the UI.

Fixes # (issue)

Requirement/Documentation

  • If there is a requirement document, please, share it here.
  • If there is ab UI/UX design document, please, share it here.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • Chore (refactoring code, technical debt, workflow improvements)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How should this be tested?

  • Are there environment variables that should be set?
  • What are the minimal test data to have?
  • What is expected (happy path) to have (input and output)?
  • Any other important info that could help to test that PR

Mandatory Tasks

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

Checklist

  • I haven't read the contributing guide
  • My code doesn't follow the style guidelines of this project
  • I haven't commented my code, particularly in hard-to-understand areas
  • I haven't checked if my PR needs changes to the documentation
  • I haven't checked if my changes generate no new warnings
  • I haven't added tests that prove my fix is effective or that my feature works
  • I haven't checked if new and existing unit tests pass locally with my changes

Copy link

vercel bot commented Dec 6, 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 Dec 6, 2023 5:22pm
dev ❌ Failed (Inspect) Dec 6, 2023 5:22pm
qa 🔄 Building (Inspect) Visit Preview 💬 Add feedback Dec 6, 2023 5:22pm
4 Ignored Deployments
Name Status Preview Comments Updated (UTC)
ai ⬜️ Ignored (Inspect) Visit Preview Dec 6, 2023 5:22pm
cal ⬜️ Ignored (Inspect) Visit Preview Dec 6, 2023 5:22pm
cal-demo ⬜️ Ignored (Inspect) Dec 6, 2023 5:22pm
ui ⬜️ Ignored (Inspect) Visit Preview Dec 6, 2023 5:22pm

Copy link
Contributor

github-actions bot commented Dec 6, 2023

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

Copy link
Contributor

github-actions bot commented Dec 6, 2023

📦 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! 🙌

Copy link

deploysentinel bot commented Dec 6, 2023

Current Playwright Test Results Summary

✅ 336 Passing - ⚠️ 31 Flaky

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

(Last updated on 12/06/2023 04:29:16pm UTC)

Run Details

Running Workflow PR Update on Github Actions

Commit: c732636

Started: 12/06/2023 04:23:53pm UTC

⚠️ Flakes

📄   apps/web/playwright/booking/multipleEmailQuestion.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
Booking With Multiple Email Question and Each Other Question Booking With Multiple Email Question and multiselect Question Multiple Email required and multiselect text required
Retry 1Initial Attempt
0.41% (1) 1 / 244 run
failed over last 7 days
2.46% (6) 6 / 244 runs
flaked over last 7 days
Booking With Multiple Email Question and Each Other Question Booking With Multiple Email Question and Radio group Question Multiple Email and Radio group not required
Retry 1Initial Attempt
0% (0) 0 / 243 runs
failed over last 7 days
1.23% (3) 3 / 243 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 User can create a seated event (2 seats as example)
Retry 1Initial Attempt
1.66% (4) 4 / 241 runs
failed over last 7 days
35.27% (85) 85 / 241 runs
flaked over last 7 days

📄   apps/web/playwright/locale.e2e.ts • 13 Flakes

Top 1 Common Error Messages

null

13 Test Cases Affected

Test Case Results

Test Case Last 7 days Failures Last 7 days Flakes
unauthorized user sees correct translations (de) should use correct translations and html attributes
Retry 1Initial Attempt
-79.53% (-202) -202 / 254 runs
failed over last 7 days
80.71% (205) 205 / 254 runs
flaked over last 7 days
unauthorized user sees correct translations (ar) should use correct translations and html attributes
Retry 1Initial Attempt
-81.27% (-204) -204 / 251 runs
failed over last 7 days
81.67% (205) 205 / 251 runs
flaked over last 7 days
unauthorized user sees correct translations (zh) should use correct translations and html attributes
Retry 1Initial Attempt
-82% (-205) -205 / 250 runs
failed over last 7 days
82% (205) 205 / 250 runs
flaked over last 7 days
unauthorized user sees correct translations (zh-CN) should use correct translations and html attributes
Retry 1Initial Attempt
-82% (-205) -205 / 250 runs
failed over last 7 days
82% (205) 205 / 250 runs
flaked over last 7 days
unauthorized user sees correct translations (zh-TW) should use correct translations and html attributes
Retry 1Initial Attempt
-81.60% (-204) -204 / 250 runs
failed over last 7 days
82% (205) 205 / 250 runs
flaked over last 7 days
unauthorized user sees correct translations (pt) should use correct translations and html attributes
Retry 1Initial Attempt
-82.33% (-205) -205 / 249 runs
failed over last 7 days
82.33% (205) 205 / 249 runs
flaked over last 7 days
unauthorized user sees correct translations (pt-br) should use correct translations and html attributes
Retry 1Initial Attempt
-82.33% (-205) -205 / 249 runs
failed over last 7 days
82.33% (205) 205 / 249 runs
flaked over last 7 days
unauthorized user sees correct translations (es-419) should use correct translations and html attributes
Retry 1Initial Attempt
-82.33% (-205) -205 / 249 runs
failed over last 7 days
82.33% (205) 205 / 249 runs
flaked over last 7 days
authorized user sees correct translations (de) should return correct translations and html attributes
Retry 1Initial Attempt
-81.12% (-202) -202 / 249 runs
failed over last 7 days
82.33% (205) 205 / 249 runs
flaked over last 7 days
authorized user sees correct translations (pt-br) should return correct translations and html attributes
Retry 1Initial Attempt
-82.93% (-204) -204 / 246 runs
failed over last 7 days
83.33% (205) 205 / 246 runs
flaked over last 7 days
authorized user sees correct translations (ar) should return correct translations and html attributes
Retry 1Initial Attempt
-82.86% (-203) -203 / 245 runs
failed over last 7 days
83.67% (205) 205 / 245 runs
flaked over last 7 days
authorized user sees changed translations (de->ar) should return correct translations and html attributes
Retry 1Initial Attempt
-23.87% (-58) -58 / 243 runs
failed over last 7 days
55.97% (136) 136 / 243 runs
flaked over last 7 days
authorized user sees changed translations (de->pt-BR) [locale1] should return correct translations and html attributes
Retry 1Initial Attempt
-29.27% (-48) -48 / 164 runs
failed over last 7 days
59.15% (97) 97 / 164 runs
flaked over last 7 days

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

Test Case Results

Test Case Last 7 days Failures Last 7 days Flakes
Onboarding Onboarding v2 Onboarding Flow
Retry 1Initial Attempt
1.10% (3) 3 / 273 runs
failed over last 7 days
0.73% (2) 2 / 273 runs
flaked over last 7 days

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

Test Case Results

Test Case Last 7 days Failures Last 7 days Flakes
Booking With Long Text Question and Each Other Question Booking With Long Text Question and select Question Long Text and select required
Retry 1Initial Attempt
0.41% (1) 1 / 245 run
failed over last 7 days
0.82% (2) 2 / 245 runs
flaked over last 7 days

📄   apps/web/playwright/organization/organization-creation.e2e.ts • 1 Flake

Test Case Results

Test Case Last 7 days Failures Last 7 days Flakes
Organization should be able to create an organization and complete onboarding
Retry 2Retry 1Initial Attempt
23.25% (63) 63 / 271 runs
failed over last 7 days
54.24% (147) 147 / 271 runs
flaked over last 7 days

📄   apps/web/playwright/login.2fa.e2e.ts • 1 Flake

Test Case Results

Test Case Last 7 days Failures Last 7 days Flakes
2FA Tests should allow a user to enable 2FA and login using 2FA
Retry 1Initial Attempt
1.57% (4) 4 / 255 runs
failed over last 7 days
25.88% (66) 66 / 255 runs
flaked over last 7 days

📄   apps/web/playwright/event-types.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
Event Types tests user -- future can add multiple organizer address
Retry 1Initial Attempt
3.13% (8) 8 / 256 runs
failed over last 7 days
11.72% (30) 30 / 256 runs
flaked over last 7 days
Event Types tests user -- future Different Locations Tests can add Attendee Phone Number location and book with it
Retry 1Initial Attempt
3.13% (8) 8 / 256 runs
failed over last 7 days
9.77% (25) 25 / 256 runs
flaked over last 7 days

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

Test Case Results

Test Case Last 7 days Failures Last 7 days Flakes
Teams - Org Can create a booking for Collective EventType
Retry 1Initial Attempt
3.52% (9) 9 / 256 runs
failed over last 7 days
0.39% (1) 1 / 256 run
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 Paid rescheduling should go to success page
Retry 1Initial Attempt
0% (0) 0 / 257 runs
failed over last 7 days
0.78% (2) 2 / 257 runs
flaked over last 7 days

📄   apps/web/playwright/team/team-invitation.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
Team Invitation (non verified)
Retry 1Initial Attempt
2.35% (6) 6 / 255 runs
failed over last 7 days
41.57% (106) 106 / 255 runs
flaked over last 7 days
Team Invitation (verified)
Retry 1Initial Attempt
0% (0) 0 / 255 runs
failed over last 7 days
12.94% (33) 33 / 255 runs
flaked over last 7 days

📄   packages/embeds/embed-core/playwright/tests/preview.e2e.ts • 1 Flake

Test Case Results

Test Case Last 7 days Failures Last 7 days Flakes
Preview Preview - embed-core should load
Retry 1Initial Attempt
0% (0) 0 / 265 runs
failed over last 7 days
21.51% (57) 57 / 265 runs
flaked over last 7 days

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

Top 1 Common Error Messages

null

3 Test Cases Affected

Test Case Results

Test Case Last 7 days Failures Last 7 days Flakes
Popup Tests should be able to reschedule
Retry 1Initial Attempt
7.14% (19) 19 / 266 runs
failed over last 7 days
87.59% (233) 233 / 266 runs
flaked over last 7 days
Popup Tests Floating Button Popup Pro User - Configured in App with default setting of system theme should open embed iframe according to system theme when no theme is configured through Embed API
Retry 1Initial Attempt
3.38% (9) 9 / 266 runs
failed over last 7 days
76.32% (203) 203 / 266 runs
flaked over last 7 days
Popup Tests should open Routing Forms embed on click
Retry 1Initial Attempt
1.89% (5) 5 / 265 runs
failed over last 7 days
41.51% (110) 110 / 265 runs
flaked over last 7 days

📄   packages/embeds/embed-core/playwright/tests/inline.e2e.ts • 1 Flake

Test Case Results

Test Case Last 7 days Failures Last 7 days Flakes
Inline Iframe Inline Iframe - Configured with Dark Theme
Retry 1Initial Attempt
3.40% (9) 9 / 265 runs
failed over last 7 days
33.96% (90) 90 / 265 runs
flaked over last 7 days

View Detailed Build Results


@alishaz-polymath alishaz-polymath marked this pull request as ready for review December 6, 2023 16:12
@alishaz-polymath alishaz-polymath added 🐛 bug Something isn't working High priority Created by Linear-GitHub Sync api area: API, enterprise API, access token, OAuth labels Dec 6, 2023
Comment on lines +22 to +26
const { usernameList, ...rest } = req.query;
let slugs = usernameList;
if (!Array.isArray(usernameList)) {
slugs = usernameList ? [usernameList] : [];
}
Copy link
Member Author

Choose a reason for hiding this comment

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

handles usernameList when only one user slug is provided. It was essential otherwise to provide an extra usernameList query parameter (empty) to satisfy the validation, as well as then had a side-effect of it being considered as a dynamic event

Comment on lines +28 to +43
const timeZoneSupported = input.timeZone ? isSupportedTimeZone(input.timeZone) : false;
const availableSlots = await getAvailableSlots({ ctx: await createContext({ req, res }), input });
const slotsInProvidedTimeZone = timeZoneSupported
? Object.keys(availableSlots.slots).reduce(
(acc: Record<string, { time: string; attendees?: number; bookingUid?: string }[]>, date) => {
acc[date] = availableSlots.slots[date].map((slot) => ({
...slot,
time: dayjs(slot.time).tz(input.timeZone).format(),
}));
return acc;
},
{}
)
: availableSlots;

return slotsInProvidedTimeZone;
Copy link
Member Author

Choose a reason for hiding this comment

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

We confirm if provided timezone is supported, and if it is, we convert the slots to the provided timezone. The timezone was not being considered otherwise as the slots would always be in Zulu.

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.

Nice find @alishaz-polymath 🙏🏽

@zomars zomars merged commit adf0126 into main Dec 6, 2023
41 of 42 checks passed
@zomars zomars deleted the fix/slots-api-fixes branch December 6, 2023 17:10
DmytroHryshyn pushed a commit to codemod-com/cal.com-demo that referenced this pull request Dec 7, 2023
hbjORbj pushed a commit to codemod-com/cal.com-demo that referenced this pull request Dec 21, 2023
haranrk pushed a commit to haranrk/cal.com that referenced this pull request Jan 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api area: API, enterprise API, access token, OAuth 🐛 bug Something isn't working core area: core, team members only High priority Created by Linear-GitHub Sync
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants