@harbortouch/skytab-analytics-report-utils 0.4.1 → 0.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +2 -1
- package/dist/index.js +2 -1
- package/dist/totals.d.ts +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -627,6 +627,7 @@ function isNumericType(type) {
|
|
|
627
627
|
|
|
628
628
|
// src/totals.ts
|
|
629
629
|
function calculateReportTotals(data, fieldConfig, opts) {
|
|
630
|
+
const rows = data;
|
|
630
631
|
const { labelField, label } = opts;
|
|
631
632
|
const fieldsToSum = /* @__PURE__ */ new Set();
|
|
632
633
|
const derivedFields = [];
|
|
@@ -648,7 +649,7 @@ function calculateReportTotals(data, fieldConfig, opts) {
|
|
|
648
649
|
}
|
|
649
650
|
const sums = {};
|
|
650
651
|
for (const field of fieldsToSum) {
|
|
651
|
-
sums[field] =
|
|
652
|
+
sums[field] = rows.reduce((acc, row) => acc + (row[field] ?? 0), 0);
|
|
652
653
|
}
|
|
653
654
|
const derived = {};
|
|
654
655
|
for (const { field, calc } of derivedFields) {
|
package/dist/index.js
CHANGED
|
@@ -578,6 +578,7 @@ function isNumericType(type) {
|
|
|
578
578
|
|
|
579
579
|
// src/totals.ts
|
|
580
580
|
function calculateReportTotals(data, fieldConfig, opts) {
|
|
581
|
+
const rows = data;
|
|
581
582
|
const { labelField, label } = opts;
|
|
582
583
|
const fieldsToSum = /* @__PURE__ */ new Set();
|
|
583
584
|
const derivedFields = [];
|
|
@@ -599,7 +600,7 @@ function calculateReportTotals(data, fieldConfig, opts) {
|
|
|
599
600
|
}
|
|
600
601
|
const sums = {};
|
|
601
602
|
for (const field of fieldsToSum) {
|
|
602
|
-
sums[field] =
|
|
603
|
+
sums[field] = rows.reduce((acc, row) => acc + (row[field] ?? 0), 0);
|
|
603
604
|
}
|
|
604
605
|
const derived = {};
|
|
605
606
|
for (const { field, calc } of derivedFields) {
|
package/dist/totals.d.ts
CHANGED
|
@@ -3,4 +3,4 @@ export interface CalculateReportTotalsOptions {
|
|
|
3
3
|
labelField: string;
|
|
4
4
|
label: string;
|
|
5
5
|
}
|
|
6
|
-
export declare function calculateReportTotals<T
|
|
6
|
+
export declare function calculateReportTotals<T>(data: T[], fieldConfig: Record<string, ColumnPresentationConfig>, opts: CalculateReportTotalsOptions): T;
|