-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwaiverRejector.js
42 lines (38 loc) · 1.1 KB
/
waiverRejector.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
const keys = require('./private/api-keys.json')
const admin = require("firebase-admin");
const fetch = require('node-fetch');
const fs = require('fs')
const moment = require('moment')
const endPoint = 'https://api.sendgrid.com/v3/contactdb/recipients'
let requestBody = []
let emails = []
admin.initializeApp({
credential: admin.credential.cert(keys.firebase),
databaseURL: "https://hyphen-hacks-2019.firebaseio.com"
});
function Person(input) {
this.email = input.email
this.name = input.name
this.referrer = 'hyphen-hacks_2019'
this.years_involved = '2019'
this.waiver_completed = 'false'
if (input.ticket_class_name === 'High school Student') {
this.role = 'attendee'
} else {
this.role = 'mentor'
}
}
const db = admin.firestore();
const peopleRef = db.collection('people');
const queryRef = peopleRef.where('waiverStatus', '<', 2);
let counter = 0;
peopleRef.get().then(data => {
data.forEach(snap => {
const person = snap.data()
if (person.waiverStatus === 2) {
counter ++
peopleRef.doc(person.id).update({waiverStatus: 0})
}
})
})
console.log('updated', counter)