disable auto availability create as we can import after user entered new availabilities (for now)

This commit is contained in:
Dobromir Popov
2024-03-29 00:36:22 +02:00
parent e68d1a3353
commit af8a62a526

View File

@ -481,21 +481,22 @@ exports.processEvents = async function (events, year, monthNumber, progressCallb
// create availability with the same date as the event. // create availability with the same date as the event.
//ToDo: add parameter to control if we want to create availability for each event. can be done whe we import previous shifts. //ToDo: add parameter to control if we want to create availability for each event. can be done whe we import previous shifts.
if (createAvailabilities) { // if (createAvailabilities) {
const dayofWeek = common.getDayOfWeekNameEnEnum(date); // const dayofWeek = common.getDayOfWeekNameEnEnum(date);
const availability = await prisma.availability.create({ // const availability = await prisma.availability.create({
data: { // data: {
publisherId: publisher.id, // publisherId: publisher.id,
dayofweek: dayofWeek, // dayofweek: dayofWeek,
startTime: startTime, // startTime: startTime,
endTime: endTime, // endTime: endTime,
name: `от график, ${publisher.firstName} ${publisher.lastName}`, // name: `от график, ${publisher.firstName} ${publisher.lastName}`,
isFromPreviousAssignment: true, // isFromPreviousAssignment: true,
isActive: true, // isActive: true,
}, // },
}); // });
console.log(`Created WEEKLY availability with ID ${availability.id} for date '${date.toDateString()}' and publisher '${publisher.firstName} ${publisher.lastName}'`); // console.log(`Created WEEKLY availability with ID ${availability.id} for date '${date.toDateString()}' and publisher '${publisher.firstName} ${publisher.lastName}'`);
} // }
const personResponse = await axiosInstance.post("/publishers", manualPub); const personResponse = await axiosInstance.post("/publishers", manualPub);
// let personId = personResponse.data.id; // let personId = personResponse.data.id;
@ -533,25 +534,25 @@ exports.processEvents = async function (events, year, monthNumber, progressCallb
//ToDo: fix findPublisherAvailability and creation of availabilities //ToDo: fix findPublisherAvailability and creation of availabilities
// check if there is an availability for this publisher on this date, and if not, create one // check if there is an availability for this publisher on this date, and if not, create one
//ToDo: check if that works //ToDo: check if that works
const availability = await data.findPublisherAvailability(publisher.id, start); // const availability = await data.findPublisherAvailability(publisher.id, start);
if (!availability && createAvailabilities) { // if (!availability && createAvailabilities) {
const dayofWeek = common.getDayOfWeekNameEnEnum(date); // const dayofWeek = common.getDayOfWeekNameEnEnum(date);
const availability = await prisma.availability.create({ // const availability = await prisma.availability.create({
data: { // data: {
publisherId: publisher.id, // publisherId: publisher.id,
//date: date, // //date: date,
dayofweek: dayofWeek, // dayofweek: dayofWeek,
//weekOfMonth: common.getWeekOfMonth(date), // //weekOfMonth: common.getWeekOfMonth(date),
startTime: start, // startTime: start,
endTime: end, // endTime: end,
name: `от предишен график, ${publisher.firstName} ${publisher.lastName}`, // name: `от предишен график, ${publisher.firstName} ${publisher.lastName}`,
isFromPreviousAssignment: true, // isFromPreviousAssignment: true,
isWithTransportIn: isWithTransport && event.shiftNr == 1, // isWithTransportIn: isWithTransport && event.shiftNr == 1,
isWithTransportOut: isWithTransport && event.shiftNr > 1, // isWithTransportOut: isWithTransport && event.shiftNr > 1,
}, // },
}); // });
console.log(`Created SYSTEM availability with ID ${availability.id} for date '${date.toDateString()}' and publisher '${publisher.firstName} ${publisher.lastName}'`); // console.log(`Created SYSTEM availability with ID ${availability.id} for date '${date.toDateString()}' and publisher '${publisher.firstName} ${publisher.lastName}'`);
} // }
console.log(`Created assignment with ID ${assignment.id} for date '${date.toDateString()}' and location '${event.placeOfEvent}'. publisher: ${publisher.firstName} ${publisher.lastName}}`); console.log(`Created assignment with ID ${assignment.id} for date '${date.toDateString()}' and location '${event.placeOfEvent}'. publisher: ${publisher.firstName} ${publisher.lastName}}`);
} }