diff options
| author | schneefux <schneefux+commit@schneefux.xyz> | 2018-05-05 23:31:56 +0200 |
|---|---|---|
| committer | schneefux <schneefux+commit@schneefux.xyz> | 2018-05-05 23:31:56 +0200 |
| commit | c8d900349a2a518c5fee9610b6a903a2ff546e50 (patch) | |
| tree | 3e99c3f388068e78743653dec46cf106437a7052 /config.js | |
| parent | 075c26e94f16379b302570e689d244edef94cb04 (diff) | |
| download | brokentalents-c8d900349a2a518c5fee9610b6a903a2ff546e50.tar.gz brokentalents-c8d900349a2a518c5fee9610b6a903a2ff546e50.zip | |
cache many small periods on disk and aggregate them
Diffstat (limited to 'config.js')
| -rw-r--r-- | config.js | 33 |
1 files changed, 30 insertions, 3 deletions
@@ -1,23 +1,50 @@ #!/usr/bin/node +const crypto = require('crypto'); + +const sha256 = (x) => crypto.createHash('sha256').update(x, 'utf8').digest('hex'); + +const hashSettings = (config) => sha256( + config.api.regions + + config.api.modes + + config.api.requestsPerInterval + + config.api.interval + + config.api.intervalUnit +).substring(0, 8); + module.exports = { api: { baseUrl: 'https://api.dc01.gamelockerapp.com', - timeout: 5, + timeout: 3, + /* available: eu, na, sg, cn, sa, ea */ regions: ['sg', 'eu', 'na'], - rpm: 5, + /* available: casual, ranked, blitz_pvp_ranked, casual_aral */ modes: ['blitz_pvp_ranked'], + /* available: 2, 3, 4, 5 */ + matchesPerRequest: 5, + /* How many equidistant requests to create + * matchesPerRequest * requestsPerInterval = sample size for that interval */ + requestsPerInterval: 5, + /* the size of a batch */ + interval: 1, + intervalUnit: 'hours', + /* How many batches to request per minute + * requestsPerInterval * intervalsPer Minute <= API key rate limit */ + intervalsPerMinute: 10, }, etl: { + /* attributes to be extracted and renamed from main API data */ participant: [ ['Winner', ['attributes', 'stats', 'winner']] ], roster: [ ], match: [ ], }, reduce: { + /* criteria or 'filters' */ group: ['Actor', 'Talent'], + /* stats */ sum: ['Level', 'Winner'], }, file: { - pattern: (moment) => `./data/${moment.week()}/${moment.toISOString()}.json`, + pattern: (moment) => `./data/${hashSettings(module.exports)}/${moment.toISOString()}.json`, }, }; |
