Skip to content

Commit

Permalink
Delete duplicate events (still possible to cause a race in sendMail)
Browse files Browse the repository at this point in the history
  • Loading branch information
hannilo committed Jul 7, 2020
1 parent 216c2f3 commit 00fec62
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion doodle/doodle.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,16 @@ function sendMail() {

//check if event exits for day i, handle
if (!stateCell.isBlank()) {
var events = CalendarApp.getCalendarById(CALENDAR_ID).getEventsForDay(new Date(dateCell.getValue()));
var events = CalendarApp.getCalendarById(CALENDAR_ID).getEventsForDay(new Date(dateCell.getValue()), {search: 'D&D'});
events.forEach(function (e) {
console.log("event for " + dateCell.getValue() + " - " + e.getTitle() + ' ' + e.getId())
});
if (events.length > 1) {
console.error(dateCell.getValue() + " has too many events : " + events.length)
for (i = 1; i < events.length; i++) {
console.error("deleting " + events[i].getTitle() + " ("+ events[i].getId() +")")
events[i].deleteEvent()
}
}

var eventId;
Expand Down

0 comments on commit 00fec62

Please sign in to comment.