summaryrefslogtreecommitdiff
path: root/backend
diff options
context:
space:
mode:
authorschneefux <schneefux+commit@schneefux.xyz>2018-05-10 13:40:40 +0200
committerschneefux <schneefux+commit@schneefux.xyz>2018-12-13 16:59:18 +0100
commit0b16c89884f8c586b5edffa612af02144e3006a2 (patch)
tree78e86f3b28f8401290e61f734bf6ae4782f9ec18 /backend
parent62abcb8f563edcd639b5dc36b6467debbfbd3215 (diff)
downloadbrokentalents-0b16c89884f8c586b5edffa612af02144e3006a2.tar.gz
brokentalents-0b16c89884f8c586b5edffa612af02144e3006a2.zip
merge 'NoTalent' and null talents
Diffstat (limited to 'backend')
-rw-r--r--backend/index.js3
-rw-r--r--backend/reduce.js8
2 files changed, 10 insertions, 1 deletions
diff --git a/backend/index.js b/backend/index.js
index 45869fb..9679a02 100644
--- a/backend/index.js
+++ b/backend/index.js
@@ -11,6 +11,7 @@ const R = require('ramda'),
const loadFTimestamped = source.loadFTimestamped(config);
const deriveStatistics = reduce.deriveStatistics(config.reduce);
const aggregatePayloads = reduce.aggregatePayloads(config.reduce);
+const cleanPayloads = reduce.cleanPayloads(config.reduce);
const saveFPayloads = file.saveFPayloads(config.file);
function main() {
@@ -22,7 +23,7 @@ function main() {
const futures = R.map(loadFTimestamped, laterMoments);
Future.parallel(1, futures)
- .map(R.compose(deriveStatistics, aggregatePayloads, R.unnest))
+ .map(R.compose(deriveStatistics, aggregatePayloads, cleanPayloads, R.unnest))
.chain(saveFPayloads(config.file.reportPattern()))
.fork(console.error, (d) => console.log(JSON.stringify(d, null, 2)));
}
diff --git a/backend/reduce.js b/backend/reduce.js
index 3ac9da2..519004c 100644
--- a/backend/reduce.js
+++ b/backend/reduce.js
@@ -3,6 +3,13 @@
const R = require('ramda'),
utils = require('./utils');
+function cleanPayloads(config) {
+ return R.map(R.pipe(
+ // some Talents are 'null', some are 'NoTalent'
+ R.over(R.lensProp('Talent'), R.defaultTo('NoTalent')),
+ ));
+}
+
function aggregatePayloads(config) {
// Ramda group() only groups neighbors, so sort beforehand
const sorter = R.props(config.group);
@@ -46,6 +53,7 @@ function deriveStatistics(config) {
}
module.exports = {
+ cleanPayloads,
aggregatePayloads,
deriveStatistics,
};