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:
parent
0ab1a804eb
commit
1edc335ca6
4
.replit
4
.replit
@ -19,10 +19,6 @@ externalPort = 80
|
||||
localPort = 33035
|
||||
externalPort = 3001
|
||||
|
||||
[[ports]]
|
||||
localPort = 37125
|
||||
externalPort = 4200
|
||||
|
||||
[[ports]]
|
||||
localPort = 41343
|
||||
externalPort = 3000
|
||||
|
||||
@ -686,7 +686,13 @@ export async function registerRoutes(app: Express): Promise<Server> {
|
||||
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<Server> {
|
||||
.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")
|
||||
)
|
||||
)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user