Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

reportjs

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

reportjs - npm Package Compare versions

Comparing version 3.0.4 to 3.0.5

52

dist/js/input/resultSet.js

@@ -20,2 +20,4 @@ 'use strict';

var KEY_SEPARATOR = '||';
var ResultSet = exports.ResultSet = function () {

@@ -61,5 +63,39 @@ function ResultSet(fields, rows) {

}, {
key: 'groupBy',
value: function groupBy(dimension1Fields, dimension2Fields) {
var _this = this;
var result = {};
this.rows.forEach(function (row) {
var dimension1FieldValues = dimension1Fields.map(function (fieldId) {
var fieldIndex = _this.getFieldIndex(fieldId);
return row[fieldIndex];
});
var dimension1Key = _this.getGroupKeyForFieldValues(dimension1FieldValues);
var dimension2FieldValues = dimension2Fields.map(function (fieldId) {
var fieldIndex = _this.getFieldIndex(fieldId);
return row[fieldIndex];
});
var dimension2Key = _this.getGroupKeyForFieldValues(dimension2FieldValues);
if (!result[dimension1Key]) {
result[dimension1Key] = {};
}
result[dimension1Key][dimension2Key] = row;
});
return result;
}
}, {
key: 'getGroupKeyForFieldValues',
value: function getGroupKeyForFieldValues(fieldValues) {
var keys = [];
fieldValues.forEach(function (fieldValue) {
keys.push(fieldValue ? fieldValue.value : '');
});
return keys.join(KEY_SEPARATOR);
}
}, {
key: 'getFieldValuesSets',
value: function getFieldValuesSets(measureFields, fields) {
var _this = this;
var _this2 = this;

@@ -80,3 +116,3 @@ var mapUtils = new _maps.Maps(),

measureFields.forEach(function (measureId) {
var measureFieldIndex = _this.getFieldIndex(measureId);
var measureFieldIndex = _this2.getFieldIndex(measureId);
var hasRows = rows.some(function (row) {

@@ -86,3 +122,3 @@ return row[measureFieldIndex].value !== null && row[measureFieldIndex].value !== undefined;

if (hasRows) {
getSets(sets, remainingFields, rows, { fieldValues: set.fieldValues, measure: _this.getField(measureId) });
getSets(sets, remainingFields, rows, { fieldValues: set.fieldValues, measure: _this2.getField(measureId) });
}

@@ -93,6 +129,6 @@ });

var currentField = _this.getField(currentFieldId),
currentFieldIndex = _this.getFieldIndex(currentFieldId);
var currentField = _this2.getField(currentFieldId),
currentFieldIndex = _this2.getFieldIndex(currentFieldId);
_this.getFieldValues(currentField).forEach(function (fieldValue) {
_this2.getFieldValues(currentField).forEach(function (fieldValue) {
var subRows = rows.filter(function (row) {

@@ -117,3 +153,3 @@ return row[currentFieldIndex] === fieldValue;

value: function getFieldValue(measureField, fieldValues) {
var _this2 = this;
var _this3 = this;

@@ -127,3 +163,3 @@ var arrayFieldValues = Array.from(fieldValues);

var fieldIndex = _this2.getFieldIndex(fieldId);
var fieldIndex = _this3.getFieldIndex(fieldId);
// I dont know why exactly I dont get the same instance of fieldValue in unit tests here

@@ -130,0 +166,0 @@ return row[fieldIndex].value === fieldValue.value;

14

dist/js/processor/graph/graphProcessor.js

@@ -12,4 +12,2 @@ 'use strict';

var _maps = require('../../utils/maps');
var _constants = require('../../constants');

@@ -51,3 +49,3 @@

var maps = new _maps.Maps();
var groupedRows = resultSet.groupBy(this.datasetsFields, this.labelsFields);
var datasetsSets = resultSet.getFieldValuesSets(this.measureFields, this.datasetsFields);

@@ -67,9 +65,11 @@ var labelsSets = resultSet.getFieldValuesSets(this.measureFields, this.labelsFields);

};
var datasetKey = resultSet.getGroupKeyForFieldValues(datasetSet.fieldValues);
datasets.push(dataset);
labelsSets.forEach(function (labelSet) {
var measure = datasetSet.measure ? datasetSet.measure : labelSet.measure;
var fieldValues = maps.sum(datasetSet.fieldValues, labelSet.fieldValues);
var fieldValue = resultSet.getFieldValue(measure, fieldValues);
if (fieldValue) {
var measureIndex = resultSet.getFieldIndex(measure.id);
var labelKey = resultSet.getGroupKeyForFieldValues(labelSet.fieldValues);
var row = groupedRows[datasetKey] ? groupedRows[datasetKey][labelKey] : false;
if (row) {
var fieldValue = row[measureIndex];
dataset.data.push(fieldValue.value);

@@ -76,0 +76,0 @@ } else {

{
"name": "reportjs",
"version": "3.0.4",
"version": "3.0.5",
"description": "Report Library",

@@ -5,0 +5,0 @@ "repository": {

import {FIELD_MEASURES} from '../constants';
import {Maps} from '../utils/maps';
const KEY_SEPARATOR = '||'
export class ResultSet {

@@ -42,2 +44,32 @@ constructor(fields, rows) {

groupBy(dimension1Fields, dimension2Fields) {
const result = {};
this.rows.forEach(row => {
const dimension1FieldValues = dimension1Fields.map(fieldId => {
const fieldIndex = this.getFieldIndex(fieldId);
return row[fieldIndex];
});
const dimension1Key = this.getGroupKeyForFieldValues(dimension1FieldValues);
const dimension2FieldValues = dimension2Fields.map(fieldId => {
const fieldIndex = this.getFieldIndex(fieldId);
return row[fieldIndex];
});
const dimension2Key = this.getGroupKeyForFieldValues(dimension2FieldValues);
if (! result[dimension1Key]) {
result[dimension1Key] = {};
}
result[dimension1Key][dimension2Key] = row;
});
return result;
}
getGroupKeyForFieldValues(fieldValues) {
const keys = [];
fieldValues.forEach(fieldValue => {
keys.push(fieldValue ? fieldValue.value : '');
});
return keys.join(KEY_SEPARATOR);
}
getFieldValuesSets(measureFields, fields) {

@@ -44,0 +76,0 @@ let mapUtils = new Maps(),

import {Graph} from '../../result/graph/graph';
import {Maps} from '../../utils/maps';
import {FIELD_MEASURES} from '../../constants';

@@ -27,3 +26,3 @@

process(resultSet) {
let maps = new Maps();
const groupedRows = resultSet.groupBy(this.datasetsFields, this.labelsFields);
let datasetsSets = resultSet.getFieldValuesSets(this.measureFields, this.datasetsFields);

@@ -39,13 +38,15 @@ let labelsSets = resultSet.getFieldValuesSets(this.measureFields, this.labelsFields);

datasetsSets.forEach(datasetSet => {
let dataset = {
const dataset = {
label: this.getLabel(resultSet, this.datasetsFields, datasetSet.fieldValues, datasetSet.measure),
data: []
};
const datasetKey = resultSet.getGroupKeyForFieldValues(datasetSet.fieldValues);
datasets.push(dataset);
labelsSets.forEach(labelSet => {
let measure = datasetSet.measure ? datasetSet.measure : labelSet.measure;
let fieldValues = maps.sum(datasetSet.fieldValues, labelSet.fieldValues);
let fieldValue = resultSet.getFieldValue(measure, fieldValues);
if (fieldValue) {
const measure = datasetSet.measure ? datasetSet.measure : labelSet.measure;
const measureIndex = resultSet.getFieldIndex(measure.id);
const labelKey = resultSet.getGroupKeyForFieldValues(labelSet.fieldValues);
const row = groupedRows[datasetKey] ? groupedRows[datasetKey][labelKey] : false;
if (row) {
const fieldValue = row[measureIndex];
dataset.data.push(fieldValue.value);

@@ -52,0 +53,0 @@ } else {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc