Skip to content

Conversation

shivraj2805
Copy link
Contributor

What does this PR do?

  • Fixes #22753: Adds explanation for credentialId and externalId in the /api-reference/v2/calendars/get-busy-times documentation.
  • Clarifies how developers can obtain these values for successfully calling the endpoint.

What was added?

📘 Added Documentation for:

  • credentialId: Refers to the ID of the connected calendar account (e.g., Google, Outlook). This is typically obtained when a user connects a calendar integration through Cal.com and a credential record is created in the database.
  • externalId: Refers to the ID of the calendar itself, retrieved from the external provider (like primary for Google Calendar). You can list calendars using the /v2/calendars API to get this.

Example:

{
  "credentialId": "cred_abc123xyz",
  "externalId": "primary"
}

Copy link

vercel bot commented Jul 26, 2025

@shivraj2805 is attempting to deploy a commit to the cal Team on Vercel.

A member of the Team first needs to authorize it.

@CLAassistant
Copy link

CLAassistant commented Jul 26, 2025

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 2 committers have signed the CLA.

✅ anikdhabal
❌ shivraj2805
You have signed the CLA already but the status is still pending? Let us recheck it.

@graphite-app graphite-app bot added the community Created by Linear-GitHub Sync label Jul 26, 2025
@graphite-app graphite-app bot requested a review from a team July 26, 2025 09:42
@github-actions github-actions bot added the docs area: docs, documentation, cal.com/docs label Jul 26, 2025
Copy link
Contributor

coderabbitai bot commented Jul 26, 2025

Walkthrough

The pull request updates the OpenAPI documentation at apps/api/v2/swagger/documentation.json by adding descriptions and examples for two query parameters on the calendars busy-times endpoint: credentialId (number) and externalId (string). The new descriptions explain what each parameter represents and where to obtain their values (/v2/credentials and listing connected calendars). Example values were added: 135 for credentialId and "user@gmail.com" for externalId. No types, required flags, or schemas were changed.

Assessment against linked issues

Objective Addressed Explanation
Clarify what credentialId is and where to obtain it (/api-reference/v2/calendars/get-busy-times) [#22753]
Clarify what externalId is and where to obtain it (/api-reference/v2/calendars/get-busy-times) [#22753]

📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 53f796e and 0beff0d.

📒 Files selected for processing (1)
  • apps/api/v2/swagger/documentation.json (2 hunks)
✅ Files skipped from review due to trivial changes (1)
  • apps/api/v2/swagger/documentation.json
✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore or @coderabbit ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

graphite-app bot commented Jul 26, 2025

Graphite Automations

"Add consumer team as reviewer" took an action on this PR • (07/26/25)

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

"Add community label" took an action on this PR • (07/26/25)

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

"Add ready-for-e2e label" took an action on this PR • (08/22/25)

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

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (3)
packages/lib/getBusyTimes.ts (2)

1-13: Complete the JSDoc – list all params & return type

The new header comment is a great start, but only two of the many parameters are documented and there is no @returns section. Consumers who rely on IntelliSense / typedoc will still have to jump into the implementation to understand the full contract.

Consider expanding the block (or linking to the type literal) so that every field accepted by _getBusyTimes is discoverable from the docs:

  /**
   * Gets busy time slots from internal bookings and connected external calendars.
+  *
+  * @returns Promise<EventBusyDetails[]>  Busy intervals with `start`/`end` Date objects
   *
   * @param credentials            …
   * @param selectedCalendars      …
+  * @param userId                 …
+  * @param startTime              ISO-8601 string
+  * @param endTime                ISO-8601 string
+  * @param beforeEventBuffer      Minutes
+  * @param afterEventBuffer       Minutes
+  * @param bypassBusyCalendarTimes When true, skips external calendar lookup
+  * … etc.
   *
   * Other params are used to customize the time window, buffers, rescheduling, etc.
   */

This keeps IDE hints trustworthy and avoids future guesswork.


135-182: Hot loop repeatedly instantiates Day.js objects – cache or use timestamps

Inside the reduce, every booking creates up to six dayjs() instances (and several toDate() conversions). For large booking lists this becomes a noticeable hotspot.

A lightweight optimisation:

-    const { id, startTime, endTime, eventType, title, ...rest } = booking;
-    const minutesToBlockBeforeEvent = …
-    const minutesToBlockAfterEvent  = …
-
-    if (rest._count?.seatsReferences) {
-      const bookedAt = `${dayjs(startTime).utc().format()}<>${dayjs(endTime).utc().format()}`;
+    const { id, startTime, endTime, eventType, title, ...rest } = booking;
+    const start = dayjs.utc(startTime);   // one instantiation
+    const end   = dayjs.utc(endTime);     // one instantiation
+
+    const minutesToBlockBeforeEvent = …
+    const minutesToBlockAfterEvent  = …
+
+    if (rest._count?.seatsReferences) {
+      const bookedAt = `${start.format()}<>${end.format()}`;-          aggregate.push({
-            start: dayjs(startTime).subtract(minutesToBlockBeforeEvent, "minute").toDate(),
-            end: dayjs(startTime).toDate(),
+          aggregate.push({
+            start: start.subtract(minutesToBlockBeforeEvent, "minute").toDate(),
+            end:   start.toDate(),
           });
       …
     }
-    aggregate.push({
-      start: dayjs(startTime).subtract(minutesToBlockBeforeEvent, "minute").toDate(),
-      end: dayjs(endTime).add(minutesToBlockAfterEvent, "minute").toDate(),
+    aggregate.push({
+      start: start.subtract(minutesToBlockBeforeEvent, "minute").toDate(),
+      end:   end.add(minutesToBlockAfterEvent, "minute").toDate(),
       title,
       source: `eventType-${eventType?.id}-booking-${id}`,
     });

Benefits:
• Cuts day-js allocations in half.
• Forces UTC consistently, avoiding accidental TZ drift.

Not critical, but aligns with the performance guideline to limit Day.js in tight loops.

docs/api-reference/v2/calendars/get-busy-times.mdx (1)

13-22: Align parameter names with code-level API

At runtime the service expects an array of credentials and a parallel list of selectedCalendars, not singular credentialId / externalId. If the REST façade truly accepts single-value fields, note that internally they are wrapped as arrays so integrators aren’t surprised when reading the TS docs or source.

A one-liner clarification is enough, for example:

credentialId(or array credentials[] if you call the TypeScript lib directly)

This keeps the public docs in sync with the implementation detail just added to getBusyTimes.ts.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ee073cd and 53f796e.

📒 Files selected for processing (2)
  • docs/api-reference/v2/calendars/get-busy-times.mdx (1 hunks)
  • packages/lib/getBusyTimes.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{js,jsx,ts,tsx}

📄 CodeRabbit Inference Engine (.cursor/rules/review.mdc)

Flag excessive Day.js use in performance-critical code. Functions like .add, .diff, .isBefore, and .isAfter are slow, especially in timezone mode. Prefer .utc() for better performance. Where possible, replace with native Date and direct .valueOf() comparisons for faster execution. Recommend using native methods or Day.js .utc() consistently in hot paths like loops.

Files:

  • packages/lib/getBusyTimes.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Install dependencies / Yarn install & cache
  • GitHub Check: Codacy Static Code Analysis

@shivraj2805 shivraj2805 mentioned this pull request Jul 26, 2025
Copy link
Contributor

This PR is being marked as stale due to inactivity.

@github-actions github-actions bot added the Stale label Aug 10, 2025
Copy link
Contributor

github-actions bot commented Aug 22, 2025

E2E results are ready!

@github-actions github-actions bot removed the Stale label Aug 23, 2025
Comment on lines 3 to 6
Fetches busy time slots from internal bookings and connected external calendars, such as Google Calendar or Outlook, based on the provided credentials and calendar IDs.

This is useful for checking calendar availability to avoid scheduling conflicts in booking systems.

Copy link
Contributor

@anikdhabal anikdhabal Aug 30, 2025

Choose a reason for hiding this comment

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

You don't need to add new mdx file, just add description into those props inside swagger file

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
community Created by Linear-GitHub Sync docs area: docs, documentation, cal.com/docs ready-for-e2e
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Issue on docs
4 participants