-
Notifications
You must be signed in to change notification settings - Fork 5
/
csse-jobfile.js
85 lines (82 loc) · 2.22 KB
/
csse-jobfile.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
79
80
81
82
83
84
85
const path = require('path')
const moment = require('moment')
const program = require('commander')
// By default try to grap latest data
program
.option('-d, --date [date]', 'Change the date of the data to be generated (defaults to yesterday)', moment().subtract(1, 'day').format('YYYY-MM-DD'))
.parse(process.argv)
const date = moment(program.date)
if (!date.isValid()) {
console.error('Invalid date, using yesterday as default')
date = moment().subtract(1, 'day')
}
module.exports = {
id: 'job',
store: 'memory',
tasks: [{
id: `csse_covid_19_daily_report_${date.format('MM-DD-YYYY')}`,
type: 'http',
options: {
url: `https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_daily_reports/${date.format('MM-DD-YYYY')}.csv`
}
}],
hooks: {
tasks: {
after: {
readCSV: {
headers: true
},
transformJson: { // Data format changed on 22/03/2020
mapping: {
Province_State: 'Province/State',
Country_Region: 'Country/Region',
Last_Update: 'Last Update',
Lat: 'Latitude',
Long_: 'Longitude'
}
},
convertToGeoJson: {
latitude: 'Latitude',
longitude: 'Longitude'
},
writeJsonFS: {
hook: 'writeJson',
store: 'fs'
},
writeJsonS3: {
hook: 'writeJson',
predicate: (item) => process.env.S3_BUCKET,
store: 's3',
key: 'covid-19/csse_covid_19_daily_reports/<%= id %>.json',
storageOptions: {
ACL: 'public-read'
}
}
}
},
jobs: {
before: {
createStores: [{
id: 'memory'
}, {
id: 'fs',
options: { path: path.join(__dirname, 'csse_covid_19_daily_reports') }
},
{
id: 's3',
options: {
client: {
accessKeyId: process.env.S3_ACCESS_KEY,
secretAccessKey: process.env.S3_SECRET_ACCESS_KEY
},
bucket: process.env.S3_BUCKET
}
}]
},
after: {
clearOutputs: {},
removeStores: ['memory', 'fs', 's3']
}
}
}
}