From 93b974c1609a0ce8ef4e15a82598476139f542f5 Mon Sep 17 00:00:00 2001 From: Nicolas Drolet Date: Fri, 12 Dec 2025 13:33:27 -0500 Subject: [PATCH] fix(presets): simplify process of updating employee profiles with deleted preset. Also removed superfluous prints that are no longer required in certain modules (testing) --- prisma/schema.prisma | 2 +- src/common/mappers/timesheet.mapper.ts | 1 - .../services/schedule-presets-delete.service.ts | 13 +++++-------- .../shifts/services/shifts-update-delete.service.ts | 1 - 4 files changed, 6 insertions(+), 11 deletions(-) diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 331acbe..0e68333 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -323,7 +323,7 @@ model Preferences { view PayPeriods { pay_year Int - pay_period_no BigInt + pay_period_no Int period_start DateTime @db.Date period_end DateTime @db.Date payday DateTime @db.Date diff --git a/src/common/mappers/timesheet.mapper.ts b/src/common/mappers/timesheet.mapper.ts index ac1599d..da77f82 100644 --- a/src/common/mappers/timesheet.mapper.ts +++ b/src/common/mappers/timesheet.mapper.ts @@ -20,7 +20,6 @@ export class EmployeeTimesheetResolver { const employee_id = await this.emailResolver.findIdByEmail(email); if (!employee_id.success) return { success: false, error: employee_id.error } const start_date = weekStartSunday(date); - console.log('start date: ', start_date); const timesheet = await db.timesheets.findFirst({ where: { employee_id: employee_id.data, start_date: start_date }, select: { id: true }, diff --git a/src/time-and-attendance/schedule-presets/services/schedule-presets-delete.service.ts b/src/time-and-attendance/schedule-presets/services/schedule-presets-delete.service.ts index 27c5544..4496dcd 100644 --- a/src/time-and-attendance/schedule-presets/services/schedule-presets-delete.service.ts +++ b/src/time-and-attendance/schedule-presets/services/schedule-presets-delete.service.ts @@ -14,17 +14,14 @@ export class SchedulePresetDeleteService { }); if (!preset) return { success: false, error: `SCHEDULE_PRESET_NOT_FOUND` }; - const employee_with_preset = await this.prisma.employees.findMany({ + await this.prisma.employees.updateMany({ where: { schedule_preset_id: preset.id }, - select: { - schedule_preset_id: true, + data: { + schedule_preset_id: null, }, + }); - if(employee_with_preset.length > 0) { - for(const employee of employee_with_preset) { - employee.schedule_preset_id = null; - } - } + await this.prisma.$transaction(async (tx) => { await tx.schedulePresetShifts.deleteMany({ where: { preset_id: preset_id } }); await tx.schedulePresets.delete({ where: { id: preset_id } }); diff --git a/src/time-and-attendance/shifts/services/shifts-update-delete.service.ts b/src/time-and-attendance/shifts/services/shifts-update-delete.service.ts index 572e04e..5c9d61e 100644 --- a/src/time-and-attendance/shifts/services/shifts-update-delete.service.ts +++ b/src/time-and-attendance/shifts/services/shifts-update-delete.service.ts @@ -64,7 +64,6 @@ export class ShiftsUpdateService { if (!timesheet.success) return { success: false, error: timesheet.error } //finds original shift - console.log('timesheet id found: ', timesheet.data.id); const original = await this.prisma.shifts.findFirst({ where: { id: dto.id, timesheet_id: timesheet.data.id }, select: shift_select,