logging, error boundry
This commit is contained in:
@ -390,43 +390,7 @@ async function filterPublishersNew(selectFields, filterDate, isExactTime = false
|
||||
|
||||
///console.log(`publishers: ${publishers.length}, WhereClause: ${JSON.stringify(whereClause)}`);
|
||||
|
||||
// include repeating weekly availabilities. generate occurrences for the month
|
||||
// convert matching weekly availabilities to availabilities for the day to make further processing easier on the client.
|
||||
publishers.forEach(pub => {
|
||||
pub.availabilities = pub.availabilities.map(avail => {
|
||||
if (avail.dayOfMonth == null) {
|
||||
if (filterAvailabilitiesByDate && !isForTheMonth) {
|
||||
// filter out repeating availabilities when on other day of week
|
||||
if (filterTimeFrom) {
|
||||
if (avail.dayofweek != dayOfWeekEnum) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
let newStart = new Date(filterDate);
|
||||
newStart.setHours(avail.startTime.getHours(), avail.startTime.getMinutes(), 0, 0);
|
||||
let newEnd = new Date(filterDate);
|
||||
newEnd.setHours(avail.endTime.getHours(), avail.endTime.getMinutes(), 0, 0);
|
||||
return {
|
||||
...avail,
|
||||
startTime: newStart,
|
||||
endTime: newEnd
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (filterAvailabilitiesByDate && !isForTheMonth) {
|
||||
if (avail.startTime >= filterTimeFrom && avail.startTime <= filterTimeTo) {
|
||||
return avail;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
return avail;
|
||||
}
|
||||
})
|
||||
.filter(avail => avail !== null);
|
||||
});
|
||||
|
||||
|
||||
// ---------------------------------------------- statistics ----------------------------------------------
|
||||
let currentWeekStart, currentWeekEnd;
|
||||
|
||||
if (isWithStats) {
|
||||
@ -494,8 +458,45 @@ async function filterPublishersNew(selectFields, filterDate, isExactTime = false
|
||||
return avail.startTime >= filterDate && avail.startTime <= filterTimeTo;
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
// ----------------------------------------------
|
||||
// include repeating weekly availabilities. generate occurrences for the month
|
||||
// convert matching weekly availabilities to availabilities for the day to make further processing easier on the client.
|
||||
publishers.forEach(pub => {
|
||||
pub.availabilities = pub.availabilities.map(avail => {
|
||||
if (avail.dayOfMonth == null) {
|
||||
if (filterAvailabilitiesByDate && !isForTheMonth) {
|
||||
// filter out repeating availabilities when on other day of week
|
||||
if (filterTimeFrom) {
|
||||
if (avail.dayofweek != dayOfWeekEnum) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
let newStart = new Date(filterDate);
|
||||
newStart.setHours(avail.startTime.getHours(), avail.startTime.getMinutes(), 0, 0);
|
||||
let newEnd = new Date(filterDate);
|
||||
newEnd.setHours(avail.endTime.getHours(), avail.endTime.getMinutes(), 0, 0);
|
||||
return {
|
||||
...avail,
|
||||
startTime: newStart,
|
||||
endTime: newEnd
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (filterAvailabilitiesByDate && !isForTheMonth) {
|
||||
if (avail.startTime >= filterTimeFrom && avail.startTime <= filterTimeTo) {
|
||||
return avail;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
return avail;
|
||||
}
|
||||
})
|
||||
.filter(avail => avail !== null);
|
||||
});
|
||||
|
||||
// ToDo: test case/unit test
|
||||
// ToDo: check and validate the filtering and calculations
|
||||
if (isExactTime) {
|
||||
|
Reference in New Issue
Block a user