summaryrefslogtreecommitdiff
path: root/backend
diff options
context:
space:
mode:
authorschneefux <schneefux+commit@schneefux.xyz>2018-06-16 20:47:59 +0200
committerschneefux <schneefux+commit@schneefux.xyz>2018-12-13 17:09:20 +0100
commita8135ad40cbeb6c0c464d57010032dc033993439 (patch)
treee9bf2c11e277b7b60bb58ab37818c0eb1c998574 /backend
parent37fda8b8f9d7a6cf812478cdcfb46a32b8e9d259 (diff)
downloadbrokentalents-a8135ad40cbeb6c0c464d57010032dc033993439.tar.gz
brokentalents-a8135ad40cbeb6c0c464d57010032dc033993439.zip
Calculate and show level scaling
Diffstat (limited to 'backend')
-rw-r--r--backend/config.js20
-rw-r--r--backend/file.js2
-rw-r--r--backend/reduce.js4
-rw-r--r--backend/source.js1
4 files changed, 22 insertions, 5 deletions
diff --git a/backend/config.js b/backend/config.js
index 172cf80..72952a2 100644
--- a/backend/config.js
+++ b/backend/config.js
@@ -1,4 +1,5 @@
#!/usr/bin/node
+const maps = require('../src/maps/maps');
const crypto = require('crypto');
@@ -10,7 +11,9 @@ const hashSettings = (config) => sha256(
config.api.modes +
config.api.requestsPerInterval +
config.api.interval +
- config.api.intervalUnit
+ config.api.intervalUnit +
+ config.etl +
+ config.reduce
).substring(0, 8);
module.exports = {
@@ -53,14 +56,25 @@ module.exports = {
match: [ ['Mode', ['attributes', 'gameMode']] ],
},
reduce: {
+ /* attributes to be calculated from other attributes */
+ derived: [
+ (entry) => {
+ if(entry.LevelBucket == undefined)
+ entry.LevelBucket = Math.max(-1, Math.floor(maps.getScaledLevel(entry) * module.exports.self.levelBuckets));
+ return entry;
+ },
+ ],
/* criteria or 'filters' */
- group: ['Actor', 'Talent', 'Mode'],
+ group: ['Actor', 'Talent', 'Mode', 'LevelBucket'],
/* stats */
- sum: ['Level', 'Winner'],
+ sum: ['Winner'],
},
file: {
pattern: (moment) => `./data/${hashSettings(module.exports)}/${moment.toISOString()}.json`,
reportPattern: () => `./data/${hashSettings(module.exports)}/report.json`,
metadataPattern: () => `./data/${hashSettings(module.exports)}/metadata.json`,
},
+ self: {
+ levelBuckets: 5,
+ },
};
diff --git a/backend/file.js b/backend/file.js
index b750921..c609232 100644
--- a/backend/file.js
+++ b/backend/file.js
@@ -15,7 +15,7 @@ function loadFPayloads(config) {
function saveFPayloads(config) {
return R.curry((file, data) =>
Future.node((cb) => fsPath.writeFile(file, JSON.stringify(data), cb))
- .map(() => data)
+ .map(() => { console.log(`stored ${file}`); return data; })
);
}
diff --git a/backend/reduce.js b/backend/reduce.js
index 519004c..87a6e40 100644
--- a/backend/reduce.js
+++ b/backend/reduce.js
@@ -15,8 +15,10 @@ function aggregatePayloads(config) {
const sorter = R.props(config.group);
const grouper = utils.eqPropses(config.group);
- // sum & count
const aggregator = R.pipe(
+ // calculate inferred attributes
+ R.map(R.apply(R.pipe, config.derived)),
+ // sum & count
R.sortBy(sorter),
R.groupWith(grouper),
R.map(
diff --git a/backend/source.js b/backend/source.js
index 0f4fd28..28f127d 100644
--- a/backend/source.js
+++ b/backend/source.js
@@ -17,6 +17,7 @@ function doFetchProcessStoreHour(config) {
const requestsForHour = (timestamp) => R.map(R.apply(loadFApi), paramsForHourSample(timestamp));
+ //return () => Future.of([]); // DEBUG
return (timestamp) => Future.parallel(1, requestsForHour(timestamp))
.map(R.compose(aggregatePayloads, R.unnest))
.chainRej((err) => { console.error(err); return Future.of({}); }) // fail silently