Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/lib/date-ranges.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ export function buildDateRanges({
);
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

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 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 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

processed.push(processDateOverride({ item, timeZone }));
}
return processed;
Expand Down
8 changes: 5 additions & 3 deletions packages/trpc/server/routers/viewer/slots/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ export async function getAvailableSlots({ input, ctx }: GetScheduleOptions) {
});

/* We get all users working hours and busy slots */
const userAvailability = await Promise.all(
const allUsersAvailability = await Promise.all(
usersWithCredentials.map(async (currentUser) => {
const {
busy,
Expand Down Expand Up @@ -448,15 +448,17 @@ export async function getAvailableSlots({ input, ctx }: GetScheduleOptions) {
const checkForAvailabilityTime = 0;
const getSlotsCount = 0;
const checkForAvailabilityCount = 0;
const aggregatedAvailability = getAggregatedAvailability(allUsersAvailability, eventType.schedulingType);

const timeSlots = getSlots({
inviteeDate: startTime,
eventLength: input.duration || eventType.length,
offsetStart: eventType.offsetStart,
dateRanges: getAggregatedAvailability(userAvailability, eventType.schedulingType),
dateRanges: aggregatedAvailability,
minimumBookingNotice: eventType.minimumBookingNotice,
frequency: eventType.slotInterval || input.duration || eventType.length,
organizerTimeZone: eventType.timeZone || eventType?.schedule?.timeZone || userAvailability?.[0]?.timeZone,
organizerTimeZone:
eventType.timeZone || eventType?.schedule?.timeZone || allUsersAvailability?.[0]?.timeZone,
});

let availableTimeSlots: typeof timeSlots = [];
Expand Down
Loading