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
This commit is contained in:
marco370 2025-10-17 16:00:28 +00:00
parent 0ab1a804eb
commit 1edc335ca6
2 changed files with 9 additions and 6 deletions

View File

@ -19,10 +19,6 @@ externalPort = 80
localPort = 33035 localPort = 33035
externalPort = 3001 externalPort = 3001
[[ports]]
localPort = 37125
externalPort = 4200
[[ports]] [[ports]]
localPort = 41343 localPort = 41343
externalPort = 3000 externalPort = 3000

View File

@ -686,7 +686,13 @@ export async function registerRoutes(app: Express): Promise<Server> {
return selectedDate >= contractStart && selectedDate <= contractEnd; 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 const dayShifts = await db
.select({ .select({
shift: shifts, shift: shifts,
@ -696,7 +702,8 @@ export async function registerRoutes(app: Express): Promise<Server> {
.leftJoin(shiftAssignments, eq(shifts.id, shiftAssignments.shiftId)) .leftJoin(shiftAssignments, eq(shifts.id, shiftAssignments.shiftId))
.where( .where(
and( and(
sql`DATE(${shifts.startTime}) = ${dateStr}`, gte(shifts.startTime, startOfDay),
lte(shifts.startTime, endOfDay),
ne(shifts.status, "cancelled") ne(shifts.status, "cancelled")
) )
) )