-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhistory.js
29 lines (23 loc) · 875 Bytes
/
history.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
const publisher = require("./publish")
const loader = require("./loader")
const regionsObs = loader.loadFromRegions("./tmp/dati-json/dpc-covid19-ita-regioni.json")
const provinceObs = loader.loadFromProvince("./tmp/dati-json/dpc-covid19-ita-province.json")
publishLatest(provinceObs, regionsObs)
async function publishLatest(fromProvince, fromRegion) {
console.log("Publishing latest data", fromProvince.length, fromRegion.length);
await publishAll(fromProvince)
await publishAll(fromRegion)
console.log("Done");
}
async function publishAll(observations) {
let count = 0;
for (const obs of observations) {
try {
console.log(++count, observations.length);
await publisher.logHistoryObservation(obs)
} catch (error) {
console.log(error)
console.log("err", obs)
}
}
}