From 1edc335ca6e3d67725b9ef715644f2327f699359 Mon Sep 17 00:00:00 2001 From: marco370 <48531002-marco370@users.noreply.replit.com> Date: Fri, 17 Oct 2025 16:00:28 +0000 Subject: [PATCH] Improve date filtering for daily shift assignments Update SQL queries to use date range comparisons for shift start times, replacing direct date string matching. Replit-Commit-Author: Agent Replit-Commit-Session-Id: e5565357-90e1-419f-b9a8-6ee8394636df Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/6d543d2c-20b9-4ea6-93fe-70fe9b1d9f80/e5565357-90e1-419f-b9a8-6ee8394636df/BjRzszS --- .replit | 4 ---- server/routes.ts | 11 +++++++++-- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/.replit b/.replit index f835bea..c50bc15 100644 --- a/.replit +++ b/.replit @@ -19,10 +19,6 @@ externalPort = 80 localPort = 33035 externalPort = 3001 -[[ports]] -localPort = 37125 -externalPort = 4200 - [[ports]] localPort = 41343 externalPort = 3000 diff --git a/server/routes.ts b/server/routes.ts index 676ff97..1dac112 100644 --- a/server/routes.ts +++ b/server/routes.ts @@ -686,7 +686,13 @@ export async function registerRoutes(app: Express): Promise { return selectedDate >= contractStart && selectedDate <= contractEnd; }); - // Ottieni turni del giorno con assegnazioni (usando SQL date comparison) + // Ottieni turni del giorno con assegnazioni + const startOfDay = new Date(dateStr); + startOfDay.setHours(0, 0, 0, 0); + + const endOfDay = new Date(dateStr); + endOfDay.setHours(23, 59, 59, 999); + const dayShifts = await db .select({ shift: shifts, @@ -696,7 +702,8 @@ export async function registerRoutes(app: Express): Promise { .leftJoin(shiftAssignments, eq(shifts.id, shiftAssignments.shiftId)) .where( and( - sql`DATE(${shifts.startTime}) = ${dateStr}`, + gte(shifts.startTime, startOfDay), + lte(shifts.startTime, endOfDay), ne(shifts.status, "cancelled") ) )