buildJoinNode(cube) { return R.compose( R.fromPairs, R.map(v => [v[0], 1]), R.toPairs )(cube.joins || {}); }
// eslint-disable-next-line no-unused-vars compile(contexts, errorReporter) { if (contexts.length === 0) { return; } // TODO: handle duplications, context names must be uniq this.contextDefinitions = R.compose( R.fromPairs, R.map(v => [v.name, this.compileContext(v)]) )(contexts); }
compile(cubes, errorReporter) { super.compile(cubes, errorReporter); const validCubes = this.cubeList.filter(cube => this.cubeValidator.isCubeValid(cube)); this.evaluatedCubes = R.fromPairs(validCubes.map(v => [v.name, v])); this.byFileName = R.groupBy(v => v.fileName, validCubes); this.primaryKeys = R.fromPairs(validCubes.map((v) => { const primaryKeyNameToSymbol = R.compose(R.find(d => d[1].primaryKey), R.toPairs)(v.dimensions || {}); return [ v.name, primaryKeyNameToSymbol && primaryKeyNameToSymbol[0] ]; })); }
timeDimensionPathsForCube(cube) { return R.compose( R.map(nameToDefinition => `${cube}.${nameToDefinition[0]}`), R.toPairs, R.filter(d => d.type === 'time') )(this.evaluatedCubes[cube].dimensions || {}); }
/** * Extract the comments from google play script array * @param {array} comments The comments array */ function extractComments (comments) { if (!comments) { return []; } debug('comments: %O', comments); return R.compose( R.take(5), R.reject(R.isNil), R.pluck(4))(comments); }
buildJoin(cubesToJoin) { if (!cubesToJoin.length) { return null; } const key = JSON.stringify(cubesToJoin); if (!this.builtJoins[key]) { const join = R.pipe( R.map( cube => this.buildJoinTreeForRoot(cube, R.without([cube], cubesToJoin)) ), R.filter(R.identity), R.sortBy(joinTree => joinTree.joins.length) )(cubesToJoin)[0]; if (!join) { throw new UserError(`Can't find join path to join ${cubesToJoin.map(v => `'${v}'`).join(', ')}`); } this.builtJoins[key] = Object.assign(join, { multiplicationFactor: R.compose( R.fromPairs, R.map(v => [v, this.findMultiplicationFactorFor(v, join.joins)]) )(cubesToJoin) }); } return this.builtJoins[key]; }
transform(cubeName, errorReporter) { const cube = this.getCubeDefinition(cubeName); const duplicateNames = R.compose( R.map(nameToDefinitions => nameToDefinitions[0]), R.toPairs, R.filter(definitionsByName => definitionsByName.length > 1), R.groupBy(nameToDefinition => nameToDefinition[0]), R.unnest, R.map(R.toPairs), R.filter(v => !!v) )([cube.measures, cube.dimensions, cube.segments]); if (duplicateNames.length > 0) { errorReporter.error(`${duplicateNames.join(', ')} defined more than once`); } return Object.assign( { cubeName: () => cube.name }, cube.measures || {}, cube.dimensions || {}, cube.segments || {} ); }
compile(cubes, errorReporter) { this.edges = R.compose( R.fromPairs, R.unnest, R.map(v => this.buildJoinEdges(v, errorReporter.inContext(`${v.name} cube`))), R.filter(this.cubeValidator.isCubeValid.bind(this.cubeValidator)) )(this.cubeEvaluator.cubeList); this.nodes = R.compose( R.map(groupedByFrom => R.fromPairs(groupedByFrom.map(join => [join.to, 1]))), R.groupBy(join => join.from), R.map(v => v[1]), R.toPairs )(this.edges); this.undirectedNodes = R.compose( R.map(groupedByFrom => R.fromPairs(groupedByFrom.map(join => [join.from, 1]))), R.groupBy(join => join.to), R.unnest, R.map(v => [v[1], { from: v[1].to, to: v[1].from }]), R.toPairs )(this.edges); this.graph = new Graph(this.nodes); }
description: cube.description, connectedComponent: this.joinGraph.connectedComponents()[cube.name], measures: R.compose( R.map((nameToMetric) => this.measureConfig(cube.name, cubeTitle, nameToMetric)), R.filter((nameToMetric) => this.isVisible(nameToMetric[1], true)), R.toPairs )(cube.measures || {}), dimensions: R.compose( R.map((nameToDimension) => ({ name: `${cube.name}.${nameToDimension[0]}`, R.toPairs )(cube.dimensions || {}), segments: R.compose( R.map((nameToSegment) => ({ name: `${cube.name}.${nameToSegment[0]}`,
getTransactionFromBlocks(transactionId) { return R.find(R.compose(R.find(R.propEq('id', transactionId)), R.prop('transactions')), this.blocks); }
let sumOfInputsAmount = R.sum(R.flatten(R.map(R.compose(R.map(R.prop('amount')), R.prop('inputs'), R.prop('data')), newBlock.transactions))) + Config.MINING_REWARD; let sumOfOutputsAmount = R.sum(R.flatten(R.map(R.compose(R.map(R.prop('amount')), R.prop('outputs'), R.prop('data')), newBlock.transactions))); let listOfTransactionIndexInputs = R.flatten(R.map(R.compose(R.map(R.compose(R.join('|'), R.props(['transaction', 'index']))), R.prop('inputs'), R.prop('data')), newBlock.transactions)); let doubleSpendingList = R.filter((x) => x >= 2, R.map(R.length, R.groupBy(x => x)(listOfTransactionIndexInputs)));
R.compose( R.filter(isScenarioType), R.flatten(), R.map(feature => feature.elements) )(features)