Skip to content

Conversation

@cubic-dev-local
Copy link

@cubic-dev-local cubic-dev-local bot commented Nov 19, 2025

## What does this PR do?

Fixes calcom#13358.

Date overrides on user's availability settings were being added to the list of slots and their calculations even when the overrides fell outside of the start/end window of the requested schedule.

Type of change

  • Chore (refactoring code, technical debt, workflow improvements)

How should this be tested?

  • Ensure test suite passes and date overrides outside of getSchedule boundaries are not included in the list of available slots

Mandatory Tasks


Summary by cubic

Skip processing date overrides that fall outside the requested start/end window. This prevents off-window overrides from affecting available slots and reduces unnecessary work.

  • Bug Fixes

    • Only process date overrides within dateFrom–dateTo when building ranges.
  • Performance

    • Compute aggregated availability once and reuse in slot generation.
    • Use allUsersAvailability for clearer naming and accurate organizer time zone selection.

Written for commit 0b01219. Summary will update automatically on new commits.

@github-actions
Copy link

github-actions bot commented Nov 19, 2025

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

Copy link

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

1 issue found across 2 files

Prompt for AI agents (all 1 issues)

Understand the root cause of the following 1 issues and fix them.


<file name="packages/lib/date-ranges.ts">

<violation number="1" location="packages/lib/date-ranges.ts:109">
Date overrides that share the start day of the request window are now skipped because the comparison uses the override’s midnight timestamp against the exact `dateFrom` time rather than day boundaries, so any request starting after midnight on that day drops a valid override.</violation>
</file>

Reply to cubic to teach it or ask questions. Re-run a review with @cubic-dev-ai review this PR

const groupedDateOverrides = groupByDate(
availability.reduce((processed: DateRange[], item) => {
if ("date" in item && !!item.date) {
if ("date" in item && !!item.date && item.date >= dateFrom && item.date <= dateTo) {
Copy link

@cubic-dev-ai cubic-dev-ai bot Nov 19, 2025

Choose a reason for hiding this comment

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

Date overrides that share the start day of the request window are now skipped because the comparison uses the override’s midnight timestamp against the exact dateFrom time rather than day boundaries, so any request starting after midnight on that day drops a valid override.

Prompt for AI agents
Address the following comment on packages/lib/date-ranges.ts at line 109:

<comment>Date overrides that share the start day of the request window are now skipped because the comparison uses the override’s midnight timestamp against the exact `dateFrom` time rather than day boundaries, so any request starting after midnight on that day drops a valid override.</comment>

<file context>
@@ -106,7 +106,7 @@ export function buildDateRanges({
   const groupedDateOverrides = groupByDate(
     availability.reduce((processed: DateRange[], item) =&gt; {
-      if (&quot;date&quot; in item &amp;&amp; !!item.date) {
+      if (&quot;date&quot; in item &amp;&amp; !!item.date &amp;&amp; item.date &gt;= dateFrom &amp;&amp; item.date &lt;= dateTo) {
         processed.push(processDateOverride({ item, timeZone }));
       }
</file context>

[internal] Confidence score: 7/10

[internal] Posted by: General AI Review Agent

Fix with Cubic

@sanxroz
Copy link

sanxroz commented Nov 21, 2025

@cubic-dev-local review this

@cubic-dev-local
Copy link
Author

@cubic-dev-local review this

@sanxroz I've started the AI code review. It'll take a few minutes to complete.

2 similar comments
@cubic-dev-local
Copy link
Author

@cubic-dev-local review this

@sanxroz I've started the AI code review. It'll take a few minutes to complete.

@cubic-dev-local
Copy link
Author

@cubic-dev-local review this

@sanxroz I've started the AI code review. It'll take a few minutes to complete.

Copy link
Author

@cubic-dev-local cubic-dev-local bot left a comment

Choose a reason for hiding this comment

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

1 issue found across 2 files

Prompt for AI agents (all 1 issues)

Understand the root cause of the following 1 issues and fix them.


<file name="packages/lib/date-ranges.ts">

<violation number="1" location="packages/lib/date-ranges.ts:109">
Date overrides on the first/last requested day are now skipped because the new guard compares the midnight override date with the exact request timestamps; convert both sides to day boundaries before filtering.</violation>
</file>

Reply to cubic to teach it or ask questions. Re-run a review with @cubic-dev-ai review this PR

const groupedDateOverrides = groupByDate(
availability.reduce((processed: DateRange[], item) => {
if ("date" in item && !!item.date) {
if ("date" in item && !!item.date && item.date >= dateFrom && item.date <= dateTo) {
Copy link
Author

@cubic-dev-local cubic-dev-local bot Nov 21, 2025

Choose a reason for hiding this comment

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

Date overrides on the first/last requested day are now skipped because the new guard compares the midnight override date with the exact request timestamps; convert both sides to day boundaries before filtering.

Prompt for AI agents
Address the following comment on packages/lib/date-ranges.ts at line 109:

<comment>Date overrides on the first/last requested day are now skipped because the new guard compares the midnight override date with the exact request timestamps; convert both sides to day boundaries before filtering.</comment>

<file context>
@@ -106,7 +106,7 @@ export function buildDateRanges({
   const groupedDateOverrides = groupByDate(
     availability.reduce((processed: DateRange[], item) =&gt; {
-      if (&quot;date&quot; in item &amp;&amp; !!item.date) {
+      if (&quot;date&quot; in item &amp;&amp; !!item.date &amp;&amp; item.date &gt;= dateFrom &amp;&amp; item.date &lt;= dateTo) {
         processed.push(processDateOverride({ item, timeZone }));
       }
</file context>

[internal] Confidence score: 7/10

[internal] Posted by: General AI Review Agent

Suggested change
if ("date" in item && !!item.date && item.date >= dateFrom && item.date <= dateTo) {
if ("date" in item && !!item.date && dayjs(item.date).isBetween(dateFrom.startOf("day"), dateTo.endOf("day"), null, "[]")) {
Fix with Cubic

Copy link
Author

@cubic-dev-local cubic-dev-local bot left a comment

Choose a reason for hiding this comment

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

No issues found across 2 files

@sanxroz
Copy link

sanxroz commented Nov 21, 2025

@cubic-dev-local review this

@cubic-dev-local
Copy link
Author

@cubic-dev-local review this

@sanxroz I've started the AI code review. It'll take a few minutes to complete.

2 similar comments
@cubic-dev-local
Copy link
Author

@cubic-dev-local review this

@sanxroz I've started the AI code review. It'll take a few minutes to complete.

@cubic-dev-local
Copy link
Author

@cubic-dev-local review this

@sanxroz I've started the AI code review. It'll take a few minutes to complete.

@sanxroz
Copy link

sanxroz commented Nov 21, 2025

@cubic-dev-local review this

@cubic-dev-local
Copy link
Author

@cubic-dev-local review this

@sanxroz I've started the AI code review. It'll take a few minutes to complete.

2 similar comments
@cubic-dev-local
Copy link
Author

@cubic-dev-local review this

@sanxroz I've started the AI code review. It'll take a few minutes to complete.

@cubic-dev-local
Copy link
Author

@cubic-dev-local review this

@sanxroz I've started the AI code review. It'll take a few minutes to complete.

Copy link
Author

@cubic-dev-local cubic-dev-local bot left a comment

Choose a reason for hiding this comment

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

No issues found across 2 files

Copy link
Author

@cubic-dev-local cubic-dev-local bot left a comment

Choose a reason for hiding this comment

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

1 issue found across 2 files

Prompt for AI agents (all 1 issues)

Understand the root cause of the following 1 issues and fix them.


<file name="packages/lib/date-ranges.ts">

<violation number="1" location="packages/lib/date-ranges.ts:109">
Filtering date overrides by `item.date &gt;= dateFrom` drops all overrides for the first requested day whenever `dateFrom` includes a time-of-day, so first-day overrides no longer adjust availability.</violation>
</file>

Reply to cubic to teach it or ask questions. Re-run a review with @cubic-dev-ai review this PR

const groupedDateOverrides = groupByDate(
availability.reduce((processed: DateRange[], item) => {
if ("date" in item && !!item.date) {
if ("date" in item && !!item.date && item.date >= dateFrom && item.date <= dateTo) {
Copy link
Author

@cubic-dev-local cubic-dev-local bot Nov 21, 2025

Choose a reason for hiding this comment

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

Filtering date overrides by item.date >= dateFrom drops all overrides for the first requested day whenever dateFrom includes a time-of-day, so first-day overrides no longer adjust availability.

Prompt for AI agents
Address the following comment on packages/lib/date-ranges.ts at line 109:

<comment>Filtering date overrides by `item.date &gt;= dateFrom` drops all overrides for the first requested day whenever `dateFrom` includes a time-of-day, so first-day overrides no longer adjust availability.</comment>

<file context>
@@ -106,7 +106,7 @@ export function buildDateRanges({
   const groupedDateOverrides = groupByDate(
     availability.reduce((processed: DateRange[], item) =&gt; {
-      if (&quot;date&quot; in item &amp;&amp; !!item.date) {
+      if (&quot;date&quot; in item &amp;&amp; !!item.date &amp;&amp; item.date &gt;= dateFrom &amp;&amp; item.date &lt;= dateTo) {
         processed.push(processDateOverride({ item, timeZone }));
       }
</file context>

[internal] Confidence score: 8/10

[internal] Posted by: General AI Review Agent

Fix with Cubic

Copy link
Author

@cubic-dev-local cubic-dev-local bot left a comment

Choose a reason for hiding this comment

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

1 issue found across 2 files

Prompt for AI agents (all 1 issues)

Understand the root cause of the following 1 issues and fix them.


<file name="packages/lib/date-ranges.ts">

<violation number="1" location="packages/lib/date-ranges.ts:109">
Filtering overrides by raw timestamp drops valid same-day overrides when `dateFrom` is later than midnight. Compare whole-day boundaries instead of exact timestamps to keep overrides that occur on the first/last day of the requested window.</violation>
</file>

Reply to cubic to teach it or ask questions. Re-run a review with @cubic-dev-ai review this PR

const groupedDateOverrides = groupByDate(
availability.reduce((processed: DateRange[], item) => {
if ("date" in item && !!item.date) {
if ("date" in item && !!item.date && item.date >= dateFrom && item.date <= dateTo) {
Copy link
Author

@cubic-dev-local cubic-dev-local bot Nov 21, 2025

Choose a reason for hiding this comment

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

Filtering overrides by raw timestamp drops valid same-day overrides when dateFrom is later than midnight. Compare whole-day boundaries instead of exact timestamps to keep overrides that occur on the first/last day of the requested window.

Prompt for AI agents
Address the following comment on packages/lib/date-ranges.ts at line 109:

<comment>Filtering overrides by raw timestamp drops valid same-day overrides when `dateFrom` is later than midnight. Compare whole-day boundaries instead of exact timestamps to keep overrides that occur on the first/last day of the requested window.</comment>

<file context>
@@ -106,7 +106,7 @@ export function buildDateRanges({
   const groupedDateOverrides = groupByDate(
     availability.reduce((processed: DateRange[], item) =&gt; {
-      if (&quot;date&quot; in item &amp;&amp; !!item.date) {
+      if (&quot;date&quot; in item &amp;&amp; !!item.date &amp;&amp; item.date &gt;= dateFrom &amp;&amp; item.date &lt;= dateTo) {
         processed.push(processDateOverride({ item, timeZone }));
       }
</file context>

[internal] Confidence score: 8/10

[internal] Posted by: General AI Review Agent

Fix with Cubic

@sanxroz
Copy link

sanxroz commented Nov 21, 2025

@cubic-dev-local review this

@cubic-dev-local
Copy link
Author

@cubic-dev-local review this

@sanxroz I've started the AI code review. It'll take a few minutes to complete.

1 similar comment
@cubic-dev-local
Copy link
Author

@cubic-dev-local review this

@sanxroz I've started the AI code review. It'll take a few minutes to complete.

@sanxroz
Copy link

sanxroz commented Nov 21, 2025

@cubic-dev-local review this

@cubic-dev-local
Copy link
Author

@cubic-dev-local review this

@sanxroz I've started the AI code review. It'll take a few minutes to complete.

1 similar comment
@cubic-dev-local
Copy link
Author

@cubic-dev-local review this

@sanxroz I've started the AI code review. It'll take a few minutes to complete.

@sanxroz
Copy link

sanxroz commented Nov 21, 2025

@cubic-dev-local review this

@cubic-dev-local
Copy link
Author

@cubic-dev-local review this

@sanxroz I've started the AI code review. It'll take a few minutes to complete.

1 similar comment
@cubic-dev-local
Copy link
Author

@cubic-dev-local review this

@sanxroz I've started the AI code review. It'll take a few minutes to complete.

@sanxroz
Copy link

sanxroz commented Nov 21, 2025

@cubic-dev-local review this

@cubic-dev-local
Copy link
Author

@cubic-dev-local review this

@sanxroz I've started the AI code review. It'll take a few minutes to complete.

1 similar comment
@cubic-dev-local
Copy link
Author

@cubic-dev-local review this

@sanxroz I've started the AI code review. It'll take a few minutes to complete.

@sanxroz
Copy link

sanxroz commented Nov 21, 2025

@cubic-dev-local review this

@cubic-dev-local
Copy link
Author

@cubic-dev-local review this

@sanxroz I've started the AI code review. It'll take a few minutes to complete.

1 similar comment
@cubic-dev-local
Copy link
Author

@cubic-dev-local review this

@sanxroz I've started the AI code review. It'll take a few minutes to complete.

@sanxroz
Copy link

sanxroz commented Nov 21, 2025

@cubic-dev-local review this

@cubic-dev-local
Copy link
Author

@cubic-dev-local review this

@sanxroz I've started the AI code review. It'll take a few minutes to complete.

1 similar comment
@cubic-dev-local
Copy link
Author

@cubic-dev-local review this

@sanxroz I've started the AI code review. It'll take a few minutes to complete.

Copy link
Author

@cubic-dev-local cubic-dev-local bot left a comment

Choose a reason for hiding this comment

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

No issues found across 2 files

@github-actions
Copy link

This PR has been marked as stale due to inactivity. If you're still working on it or need any help, please let us know or update the PR to keep it active.

@github-actions github-actions bot added the Stale label Nov 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants