correctly assume if assignmen is old, new database fields suggestions

This commit is contained in:
Dobromir Popov
2024-02-28 23:22:10 +02:00
parent 4d4f912644
commit 7ebf442adc
3 changed files with 23 additions and 11 deletions

View File

@ -143,6 +143,8 @@ export default function ImportPage() {
//sleep for 300ms to allow the database to process the previous request
await new Promise(r => setTimeout(r, 100));
let isOld = false;
const row = rawData[i];
var email, phone, names, dateOfInput, oldAvDeleted = false, isTrained = false, desiredShiftsPerMonth = 4, isActive = false, publisherType = PublisherType.Publisher;
//const date = new Date(row[0]).toISOS{tring().slice(0, 10);
@ -162,6 +164,7 @@ export default function ImportPage() {
names = row[headerRef.current.nameIndex].normalize('NFC').split(/[ ]+/);
dateOfInput = importDate.value || new Date().toISOString();
// not empty == true
isTrained = row[headerRef.current.isTrainedIndex] !== '';
isActive = row[headerRef.current.isActiveIndex] == '';
desiredShiftsPerMonth = row[headerRef.current.desiredShiftsIndex] !== '' ? row[headerRef.current.desiredShiftsIndex] : 4;
@ -174,6 +177,15 @@ export default function ImportPage() {
}
//remove special characters from name
const day = new Date();
day.setDate(1); // Set to the first day of the month to avoid overflow
// Calculate the total month difference by considering the year difference
let totalMonthDifference = (day.getFullYear() - dateOfInput.getFullYear()) * 12 + (day.getMonth() - dateOfInput.getMonth());
// If the total month difference is 2 or more, set isOld to true
if (totalMonthDifference >= 0) {
isOld = true;
}
// let names = common.removeAccentsAndSpecialCharacters(row[2]).split(/[, ]+/);
@ -361,6 +373,7 @@ export default function ImportPage() {
// Create a new Date object for the start date of the range
const day = new Date();
day.setDate(1); // Set to the first day of the month to avoid overflow
//day.setMonth(day.getMonth() + 1); // Add one month to the date, because we assume we are p
day.setMonth(common.getMonthIndex(month));
day.setDate(parseInt(weekStart) + dayOfWeek);
@ -432,13 +445,6 @@ export default function ImportPage() {
let minStartTime = parsedIntervals[0].start;
let maxEndTime = parsedIntervals[0].end;
let isOld = false;
// Calculate the total month difference by considering the year difference
let totalMonthDifference = (day.getFullYear() - dateOfInput.getFullYear()) * 12 + (day.getMonth() - dateOfInput.getMonth());
// If the total month difference is 2 or more, set isOld to true
if (totalMonthDifference >= 2) {
isOld = true;
}
// Iterate over intervals
for (let i = 1; i < parsedIntervals.length; i++) {
@ -520,7 +526,7 @@ export default function ImportPage() {
name,
dayofweek: dayOfWeekName,
dayOfMonth,
weekOfMonth: weekNr, // Add the missing 'weekOfMonth' property
weekOfMonth: weekNr, // Add the missing 'weekOfMonth'
startTime,
endTime,
isactive: true,