@objectstack/service-analytics 15.1.0 → 16.0.0-rc.0
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 +33 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +34 -1
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -1748,6 +1748,39 @@ var AnalyticsService = class {
|
|
|
1748
1748
|
for (const d of drillDims) raw[d.name] = row[d.name];
|
|
1749
1749
|
return raw;
|
|
1750
1750
|
});
|
|
1751
|
+
if (result.totals?.length) {
|
|
1752
|
+
result.drillRawTotals = result.totals.map((total) => {
|
|
1753
|
+
const groupingDims = drillDims.filter((d) => total.dimensions.includes(d.name));
|
|
1754
|
+
return total.rows.map((row) => {
|
|
1755
|
+
const raw = {};
|
|
1756
|
+
for (const d of groupingDims) raw[d.name] = row[d.name];
|
|
1757
|
+
return raw;
|
|
1758
|
+
});
|
|
1759
|
+
});
|
|
1760
|
+
}
|
|
1761
|
+
}
|
|
1762
|
+
const rangeTz = selection.timezone ?? context?.timezone ?? "UTC";
|
|
1763
|
+
const rangeDims = [];
|
|
1764
|
+
for (const d of selectedDims) {
|
|
1765
|
+
if (!d.field || d.type !== "date" || !d.dateGranularity) continue;
|
|
1766
|
+
const ftype = this.measureCurrency?.(dataset.object, d.field)?.type;
|
|
1767
|
+
if (ftype === "datetime") rangeDims.push({ d, instant: true });
|
|
1768
|
+
else if (ftype === "date") rangeDims.push({ d, instant: false });
|
|
1769
|
+
else if (rangeTz === "UTC") rangeDims.push({ d, instant: false });
|
|
1770
|
+
}
|
|
1771
|
+
if (rangeDims.length && result.rows.length) {
|
|
1772
|
+
const bound = (ymd, instant) => instant ? new Date((0, import_core2.zonedDateStartToUtcMs)(ymd, rangeTz)).toISOString() : ymd;
|
|
1773
|
+
result.drillRanges = result.rows.map((row) => {
|
|
1774
|
+
const ranges = {};
|
|
1775
|
+
for (const { d, instant } of rangeDims) {
|
|
1776
|
+
const cal = (0, import_core2.bucketKeyToCalendarRange)(row[d.name], d.dateGranularity);
|
|
1777
|
+
if (cal) {
|
|
1778
|
+
ranges[d.name] = { field: d.field, gte: bound(cal.start, instant), lt: bound(cal.end, instant) };
|
|
1779
|
+
}
|
|
1780
|
+
}
|
|
1781
|
+
return ranges;
|
|
1782
|
+
});
|
|
1783
|
+
result.object = dataset.object;
|
|
1751
1784
|
}
|
|
1752
1785
|
if (this.labelResolver && selectedDims.length) {
|
|
1753
1786
|
const dims = selectedDims.filter((d) => !!d.field).map((d) => ({ name: d.name, field: d.field, type: d.type, dateGranularity: d.dateGranularity }));
|