Update logs to use template strings
This commit is contained in:
parent
180ae1f444
commit
309612cc13
|
|
@ -7,7 +7,7 @@ module.exports = async (req, res) => {
|
||||||
|
|
||||||
const threeMonthsAgo = dayjs().subtract(3, 'month').unix();
|
const threeMonthsAgo = dayjs().subtract(3, 'month').unix();
|
||||||
|
|
||||||
console.log('Running cleanup task at', dayjs().format('h:mma D MMM YYYY'));
|
console.log(`Running cleanup task at ${dayjs().format('h:mma D MMM YYYY')}`);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Fetch events that haven't been visited in over 3 months
|
// Fetch events that haven't been visited in over 3 months
|
||||||
|
|
@ -16,7 +16,7 @@ module.exports = async (req, res) => {
|
||||||
|
|
||||||
if (oldEvents && oldEvents.length > 0) {
|
if (oldEvents && oldEvents.length > 0) {
|
||||||
let oldEventIds = oldEvents.map(e => e[req.datastore.KEY].name);
|
let oldEventIds = oldEvents.map(e => e[req.datastore.KEY].name);
|
||||||
console.log('Found', oldEventIds.length, 'events to remove');
|
console.log(`Found ${oldEventIds.length} events to remove`);
|
||||||
|
|
||||||
// Fetch availabilities linked to the events discovered
|
// Fetch availabilities linked to the events discovered
|
||||||
let peopleDiscovered = 0;
|
let peopleDiscovered = 0;
|
||||||
|
|
@ -32,11 +32,11 @@ module.exports = async (req, res) => {
|
||||||
|
|
||||||
await req.datastore.delete(oldEvents.map(event => event[req.datastore.KEY]));
|
await req.datastore.delete(oldEvents.map(event => event[req.datastore.KEY]));
|
||||||
|
|
||||||
console.log('Cleanup successful:', oldEventIds.length, 'events and', peopleDiscovered, 'people removed');
|
console.log(`Cleanup successful: ${oldEventIds.length} events and ${peopleDiscovered} people removed`);
|
||||||
|
|
||||||
res.sendStatus(200);
|
res.sendStatus(200);
|
||||||
} else {
|
} else {
|
||||||
console.log('Found', 0, 'events to remove, ending cleanup');
|
console.log(`Found 0 events to remove, ending cleanup`);
|
||||||
res.sendStatus(404);
|
res.sendStatus(404);
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ module.exports = async (req, res) => {
|
||||||
|
|
||||||
const threeMonthsAgo = dayjs().subtract(3, 'month').unix();
|
const threeMonthsAgo = dayjs().subtract(3, 'month').unix();
|
||||||
|
|
||||||
console.log('Running LEGACY cleanup task at', dayjs().format('h:mma D MMM YYYY'));
|
console.log(`Running LEGACY cleanup task at ${dayjs().format('h:mma D MMM YYYY')}`);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Fetch events that haven't been visited in over 3 months
|
// Fetch events that haven't been visited in over 3 months
|
||||||
|
|
@ -17,7 +17,7 @@ module.exports = async (req, res) => {
|
||||||
oldEvents = oldEvents.filter(event => !event.hasOwnProperty('visited'));
|
oldEvents = oldEvents.filter(event => !event.hasOwnProperty('visited'));
|
||||||
|
|
||||||
if (oldEvents && oldEvents.length > 0) {
|
if (oldEvents && oldEvents.length > 0) {
|
||||||
console.log('Found', oldEvents.length, 'events that were missing a visited date');
|
console.log(`Found ${oldEvents.length} events that were missing a visited date`);
|
||||||
|
|
||||||
// Filter events that are older than 3 months and missing a visited date
|
// Filter events that are older than 3 months and missing a visited date
|
||||||
oldEvents = oldEvents.filter(event => event.created < threeMonthsAgo);
|
oldEvents = oldEvents.filter(event => event.created < threeMonthsAgo);
|
||||||
|
|
@ -50,11 +50,11 @@ module.exports = async (req, res) => {
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
console.log('Legacy cleanup successful:', eventsRemoved, 'events and', peopleRemoved, 'people removed');
|
console.log(`Legacy cleanup successful: ${eventsRemoved} events and ${peopleRemoved} people removed`);
|
||||||
|
|
||||||
res.sendStatus(200);
|
res.sendStatus(200);
|
||||||
} else {
|
} else {
|
||||||
console.log('Found', 0, 'events that are older than 3 months and missing a visited date, ending LEGACY cleanup');
|
console.log('Found 0 events that are older than 3 months and missing a visited date, ending LEGACY cleanup');
|
||||||
res.sendStatus(404);
|
res.sendStatus(404);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue