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 /source.js | |
| parent | ded191658af266a764332b9a1b72d628de3d5b6e (diff) | |
| download | brokentalents-5caf4e48174533710243e8eeaf52567795ec9d01.tar.gz brokentalents-5caf4e48174533710243e8eeaf52567795ec9d01.zip | |
move files to backend subdir, push data in submodule
Diffstat (limited to 'source.js')
| -rw-r--r-- | source.js | 39 |
1 files changed, 0 insertions, 39 deletions
diff --git a/source.js b/source.js deleted file mode 100644 index 0f4fd28..0000000 --- a/source.js +++ /dev/null @@ -1,39 +0,0 @@ -#!/usr/bin/node - -const R = require('ramda'), - Future = require('fluture'), - etl = require('./etl'), - params = require('./params'), - reduce = require('./reduce'), - file = require('./file'); - -function doFetchProcessStoreHour(config) { - const intervalSleep = 60 / config.api.intervalsPerMinute * 1000; - - const paramsForHourSample = params.paramsForHourSample(config.api); - const loadFApi = etl.loadFPayloads(config.etl); - const saveFPayloads = file.saveFPayloadsTimestamped(config.file); - const aggregatePayloads = reduce.aggregatePayloads(config.reduce); - - const requestsForHour = (timestamp) => R.map(R.apply(loadFApi), paramsForHourSample(timestamp)); - - return (timestamp) => Future.parallel(1, requestsForHour(timestamp)) - .map(R.compose(aggregatePayloads, R.unnest)) - .chainRej((err) => { console.error(err); return Future.of({}); }) // fail silently - .chain(saveFPayloads(timestamp)); - //.chain(Future.after(intervalSleep)); - // TODO should sleep after request; throttling rpm should happen - // at a higher level though. CPU / IO / AWS requests stall - // as well -} - -function loadFTimestamped(config) { - // load from file or fall back to API and store - return (timestamp) => - file.loadFPayloads(config)(config.file.pattern(timestamp)) - .or(doFetchProcessStoreHour(config)(timestamp)); -}; - -module.exports = { - loadFTimestamped, -}; |
