-
Notifications
You must be signed in to change notification settings - Fork 0
/
TriggerCatcher.js
27 lines (24 loc) · 1 KB
/
TriggerCatcher.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
function processCalFromTrigger(input) {
console.log("calendarId found:" + input.calendarId);
// get Calendar events for 28 days out
// split and find events that need action because they are missing cleaning, or don't have a need to be cleaned because an event was removed or moved.
async function processRemovals(){
let events = await listEvents(input.calendarId, 28);
var bookings,cleanings;
[bookings, cleanings] = splitCleaningEvents(events);
var toBeDeleted;
var toBeCleaned;
[toBeDeleted, toBeCleaned ] = processEvents(cleanings, bookings);
removeOrphans(input.calendarId, toBeDeleted);
}
async function processAdds(){
let events = await listEvents(input.calendarId, 28);
var bookings,cleanings;
[bookings, cleanings] = splitCleaningEvents(events);
var toBeDeleted;
var toBeCleaned;
[toBeDeleted, toBeCleaned ] = processEvents(cleanings, bookings);
addCleaningEvent(input.calendarId, toBeCleaned);
}
processRemovals().then(processAdds());
}