fix(shifts): commented unused service function

This commit is contained in:
Matthieu Haineault 2025-11-06 11:10:25 -05:00
parent c0189dc61d
commit 4e48d98c0f
2 changed files with 27 additions and 27 deletions

View File

@ -250,7 +250,7 @@
},
"/timesheets": {
"get": {
"operationId": "TimesheetController_getTimesheetByIds",
"operationId": "TimesheetController_getTimesheetByPayPeriod",
"parameters": [
{
"name": "year",

View File

@ -24,37 +24,37 @@ export class ShiftsGetService {
){}
//fetch a shift using shift_id and return all that shift's info
async getShiftByShiftId(shift_ids: number[]): Promise<GetShiftDto[]> {
if(!Array.isArray(shift_ids) || shift_ids.length === 0) return [];
// async getShiftByShiftId(shift_ids: number[]): Promise<GetShiftDto[]> {
// if(!Array.isArray(shift_ids) || shift_ids.length === 0) return [];
const rows = await this.prisma.shifts.findMany({
where: { id: { in: shift_ids } },
select: shift_select,
});
// const rows = await this.prisma.shifts.findMany({
// where: { id: { in: shift_ids } },
// select: shift_select,
// });
if(rows.length !== shift_ids.length) {
const found_ids = new Set(rows.map(row => row.id));
const missing_ids = shift_ids.filter(id => !found_ids.has(id));
throw new NotFoundException(`Shift(s) not found: ${ missing_ids.join(", ")}`);
}
// if(rows.length !== shift_ids.length) {
// const found_ids = new Set(rows.map(row => row.id));
// const missing_ids = shift_ids.filter(id => !found_ids.has(id));
// throw new NotFoundException(`Shift(s) not found: ${ missing_ids.join(", ")}`);
// }
const row_by_id = new Map(rows.map(row => [row.id, row]));
// const row_by_id = new Map(rows.map(row => [row.id, row]));
return shift_ids.map((id) => {
const shift = row_by_id.get(id)!;
return {
timesheet_id: shift.timesheet_id,
type: shift.bank_code.type,
date: toStringFromDate(shift.date),
start_time: toStringFromHHmm(shift.start_time),
end_time: toStringFromHHmm(shift.end_time),
is_remote: shift.is_remote,
is_approved: shift.is_approved,
comment: shift.comment ?? undefined,
} satisfies GetShiftDto;
});
// return shift_ids.map((id) => {
// const shift = row_by_id.get(id)!;
// return {
// timesheet_id: shift.timesheet_id,
// type: shift.bank_code.type,
// date: toStringFromDate(shift.date),
// start_time: toStringFromHHmm(shift.start_time),
// end_time: toStringFromHHmm(shift.end_time),
// is_remote: shift.is_remote,
// is_approved: shift.is_approved,
// comment: shift.comment ?? undefined,
// } satisfies GetShiftDto;
// });
}
// }
}