-
Notifications
You must be signed in to change notification settings - Fork 1
/
Trigger.js
78 lines (54 loc) · 2.39 KB
/
Trigger.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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
function add_NewSubscriberIDs_OfToday_To_TheExistingArrayOfSubscribers_InTheFile_Trigger() {
var today = new Date();
today.setHours(today.getHours() - 6);
var yesterday = new Date(today);
yesterday.setDate(yesterday.getDate() - 1);
var SP_Objet = JSON.parse(DriveApp.getFileById(QMedic_ScubscriberIDs_FileID).getBlob().getDataAsString());
//SP_Objet.length=500;
//PropertiesService.getUserProperties().setProperty("index",SP_Objet.indexOf(16));return;
//Logger.log(SP_Objet.indexOf(16));return;
var counter = Number(PropertiesService.getUserProperties().getProperty("index"));
counter = (counter >= SP_Objet.length) ? SP_Objet.indexOf(16) : counter;
while (counter < SP_Objet.length) {
//var error = main(new Date("2019/12/27"),SP_Objet[counter]);
if ((main(yesterday, SP_Objet[counter])) === 'Service invoked too many times for one day: urlfetch.') {
return;
}
main(today, SP_Objet[counter]);
counter++
PropertiesService.getUserProperties().setProperty("index", counter);
}
}
function updateMax_NUMBER_OF_SUBSCRIBERS() {
var SP_Objet = JSON.parse(DriveApp.getFileById(QMedic_ScubscriberIDs_FileID).getBlob().getDataAsString());
var Max_NUMBER_OF_SUBSCRIBERS =SP_Objet[SP_Objet.length-1];
var currentSubscriberId = Max_NUMBER_OF_SUBSCRIBERS;
var aupperLimit = currentSubscriberId + 20;
while (++currentSubscriberId <aupperLimit ) {
try {
QMedicEventsFromS3Only.getEvents(currentSubscriberId, new Date());
SP_Objet.push(currentSubscriberId)
main(new Date(),currentSubscriberId);
DriveApp.getFileById(QMedic_ScubscriberIDs_FileID).setContent(JSON.stringify(SP_Objet));
}
catch (e) {
console.error(e);
}
}
}
//function updateMax_NUMBER_OF_SUBSCRIBERS() {
// var SP_Objet = JSON.parse(DriveApp.getFileById(QMedic_ScubscriberIDs_FileID).getBlob().getDataAsString());
// var Max_NUMBER_OF_SUBSCRIBERS = SP_Objet[SP_Objet.length-1];
// var currentSubscriberId = Max_NUMBER_OF_SUBSCRIBERS;
// var aupperLimit = currentSubscriberId + 20;
// while (++currentSubscriberId <aupperLimit ) {
// try {
// getEvents(currentSubscriberId, new Date());
// SP_Objet.push(currentSubscriberId)
// main(new Date(),currentSubscriberId);
// DriveApp.getFileById(QMedic_ScubscriberIDs_FileID).setContent(JSON.stringify(SP_Objet));
// }
// catch (e) {
// }
// }
//}