-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
76 lines (66 loc) · 2.13 KB
/
index.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
import yargs from 'yargs/yargs'
import urlHelper from './url.js'
import dataHelper from './data.js'
var argv = yargs(process.argv.slice(2))
.coerce('player', function (arg) {
let response = []
switch (typeof arg) {
case "string":
response = [arg.split(" ").join("+")]
break;
case "object":
response = arg.map(val => val.split(" ").join("+"))
break;
default:
console.warn('Unknown player parameter')
break;
}
return response
}).coerce('team', function (arg) {
let response = arg
if (typeof arg == "string") {
response = [arg]
}
return response
}).argv
const config = {
PlayerMovementChkBx: !!argv.PlayerMovementChkBx, // Player/Coach/Executive movement (trades, free agent signings, draft picks, etc.)
ILChkBx: !!argv.ILChkBx, // Movement to/from injured/inactive list (IL)
NBADLChkBx: !!argv.NBADLChkBx, // NBADL / G League movements
InjuriesChkBx: !!argv.InjuriesChkBx, // Missed games due to injury
PersonalChkBx: !!argv.PersonalChkBx, // Missed games due to personal reasons
DisciplinaryChkBx: !!argv.DisciplinaryChkBx, // Disciplinary actions (suspensions, fines, etc.)
LegalChkBx: !!argv.LegalChkBx, // Legal/Criminal incidents
}
const dates = {
beginDate: argv.beginDate ?? '',
endDate: argv.endDate ?? '',
}
console.log('---ARGUMENTS---')
console.table({
player: argv.player,
team: argv.team,
config,
dates
})
if (!Object.values(config).includes(true)) {
throw new Error('No Transaction Type boxes were checked')
}
async function main() {
const players = argv.player ?? []
const teams = argv.team ?? []
let initialURLs = urlHelper.getURLs(players, teams, config, dates)
let idx = 0
for (const { player, team, address } of initialURLs) {
const data = await dataHelper.getAllData(address)
dataHelper.saveData(idx, {
player,
team,
config,
dates,
data
})
idx++;
}
}
await main()