-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
47 lines (45 loc) · 2.01 KB
/
app.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
const fs = require("fs");
const { saveToJson } = require("./miscellaneous_js/functions");
const { getSenNamesAndPhotos } = require("./puppeteer/names_and_photos/index");
const {
getSenContributions,
} = require("./puppeteer/get_contributions/index.js");
const {
parseContributions,
getTop500Contributors,
} = require("./puppeteer/parse_contributions/index");
const {
pushSenStatsAndPhotosToFirestoreAndCloudStorage,
readMetaSTATSandPushToFirestore,
} = require("./firebase/index");
const getSenatorsAndIDs = async () => {
// NOTE: reassigning const senArray between states for testing purposes so can work on small parts. comment out to run entire app.
///////////////// STAGE 1 /////////////////
// get all senator data and photos; save array to senatorArray.json, save photos to /pics
const senArray = await getSenNamesAndPhotos();
await saveToJson(`./json/senArray.json`, JSON.stringify(senArray));
///////////////// STAGE 2 /////////////////
// get all contributions for each senator
// const senArray = JSON.parse(fs.readFileSync("./json/senArray.json", "utf-8"));
for (let sen of senArray) {
await getSenContributions(sen);
}
////////////////// STAGE 3 //////////////////
// parse contributions, getting top contributors, buckets
// const senArray = JSON.parse(fs.readFileSync("./json/senArray.json", "utf-8"));
for (let sen of senArray) {
await parseContributions(sen);
}
////////////////// STAGE 4 //////////////////
// push individual senatorSTATS files and photos to firestore
// const senArray = JSON.parse(fs.readFileSync("./json/senArray.json", "utf-8"));
for (let sen of senArray) {
pushSenStatsAndPhotosToFirestoreAndCloudStorage(sen);
}
////////////////// STAGE 5 //////////////////
// create meta (aggregate) file for top 500 contributors and push to firestore
// const senArray = JSON.parse(fs.readFileSync("./json/senArray.json", "utf-8"));
getTop500Contributors(senArray); // writes metaSTATSpartial to ./json
readMetaSTATSandPushToFirestore();
};
getSenatorsAndIDs();