diff options
| author | schneefux <schneefux+commit@schneefux.xyz> | 2018-05-07 09:06:04 +0200 |
|---|---|---|
| committer | schneefux <schneefux+commit@schneefux.xyz> | 2018-05-07 09:06:04 +0200 |
| commit | 5caf4e48174533710243e8eeaf52567795ec9d01 (patch) | |
| tree | 1396f09bd14c3c4e1af3164ef924f2190b3f949f /params.js | |
| parent | ded191658af266a764332b9a1b72d628de3d5b6e (diff) | |
| download | brokentalents-5caf4e48174533710243e8eeaf52567795ec9d01.tar.gz brokentalents-5caf4e48174533710243e8eeaf52567795ec9d01.zip | |
move files to backend subdir, push data in submodule
Diffstat (limited to 'params.js')
| -rw-r--r-- | params.js | 39 |
1 files changed, 0 insertions, 39 deletions
diff --git a/params.js b/params.js deleted file mode 100644 index 5edf658..0000000 --- a/params.js +++ /dev/null @@ -1,39 +0,0 @@ -#!/usr/bin/node - -const R = require('ramda'), - moment = require('moment'); - -function paramsForHourSample(config) { - const requestArgsForRegionStartEnd = R.curry((region, start, end) => [ - `/shards/${region}/matches`, { - 'sort': '-createdAt', - 'filter[gameMode]': R.join(',', config.modes), - 'filter[createdAt-start]': start.toISOString(), - 'filter[createdAt-end]': end.toISOString(), - 'page[limit]': config.matchesPerRequest, - 'page[offset]': '0', - } - ]); - - const intervalMinutes = moment.duration(config.interval, config.intervalUnit).as('minutes'); - const requestsPerMinutePerRegion = Math.floor(config.requestsPerInterval / config.regions.length); - const splitDurationMinutes = Math.floor(intervalMinutes / requestsPerMinutePerRegion); - const splitMoments = (hour) => R.map( - (offsetIndex) => [ - hour.clone().minutes(offsetIndex * splitDurationMinutes), - hour.clone().minutes((offsetIndex + 1) * splitDurationMinutes), - ], - R.range(0, requestsPerMinutePerRegion), - ); - - return R.pipe( - splitMoments, - R.xprod(config.regions), - R.map(R.unnest), - R.map(R.apply(requestArgsForRegionStartEnd)), - ); -} - -module.exports = { - paramsForHourSample, -}; |
