@lightdash/common 0.1402.0 → 0.1403.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/types/catalog.d.ts
CHANGED
|
@@ -146,4 +146,8 @@ export type ChartUsageIn = CatalogFieldWhere & {
|
|
|
146
146
|
chartUsage: number;
|
|
147
147
|
};
|
|
148
148
|
export declare const indexCatalogJob = "indexCatalog";
|
|
149
|
+
export type ApiMetricsWithAssociatedTimeDimensionResponse = {
|
|
150
|
+
status: 'ok';
|
|
151
|
+
results: MetricWithAssociatedTimeDimension[];
|
|
152
|
+
};
|
|
149
153
|
export {};
|
|
@@ -24,6 +24,7 @@ export type MetricExploreDataPoint = {
|
|
|
24
24
|
};
|
|
25
25
|
export type MetricsExplorerQueryResults = {
|
|
26
26
|
metric: MetricWithAssociatedTimeDimension;
|
|
27
|
+
comparisonMetric: MetricWithAssociatedTimeDimension | undefined;
|
|
27
28
|
rows: ResultRow[];
|
|
28
29
|
comparisonRows: ResultRow[] | undefined;
|
|
29
30
|
fields: ItemsMap;
|
|
@@ -17,7 +17,7 @@ export declare const oneYearForward: (date: Date) => Date;
|
|
|
17
17
|
export declare const getGrainForDateRange: (dateRange: [Date, Date]) => ImpelemntedTimeframe;
|
|
18
18
|
export declare const getMetricExplorerDateRangeFilters: (exploreName: string, dimensionName: string, dateRange: MetricExplorerDateRange) => DateFilter[];
|
|
19
19
|
export declare const getMetricExplorerDataPoints: (dimension: Dimension, metric: MetricWithAssociatedTimeDimension, metricRows: ResultRow[]) => Array<MetricExploreDataPoint>;
|
|
20
|
-
export declare const getMetricExplorerDataPointsWithCompare: (dimension: Dimension, metric: MetricWithAssociatedTimeDimension, metricRows: ResultRow[], compareMetricRows: ResultRow[], comparison: MetricExplorerComparisonType) => Array<MetricExploreDataPoint>;
|
|
20
|
+
export declare const getMetricExplorerDataPointsWithCompare: (dimension: Dimension, compareDimension: Dimension, metric: MetricWithAssociatedTimeDimension, metricRows: ResultRow[], compareMetricRows: ResultRow[], comparison: MetricExplorerComparisonType) => Array<MetricExploreDataPoint>;
|
|
21
21
|
/**
|
|
22
22
|
* Get the date range for a given time interval, based on the current date and the time interval
|
|
23
23
|
* Time grain Year: -> past 5 years (i.e. 5 completed years + this uncompleted year)
|
|
@@ -100,7 +100,7 @@ exports.getMetricExplorerDateRangeFilters = getMetricExplorerDateRangeFilters;
|
|
|
100
100
|
const getMetricExplorerDataPoints = (dimension, metric, metricRows) => {
|
|
101
101
|
const dimensionId = (0, item_1.getItemId)(dimension);
|
|
102
102
|
const metricId = (0, item_1.getItemId)(metric);
|
|
103
|
-
const groupByMetricRows = (0, lodash_1.groupBy)(metricRows, (row) => new Date(String(row[dimensionId].value.raw)).
|
|
103
|
+
const groupByMetricRows = (0, lodash_1.groupBy)(metricRows, (row) => new Date(String(row[dimensionId].value.raw)).toISOString());
|
|
104
104
|
return Object.keys(groupByMetricRows).map((date) => ({
|
|
105
105
|
date: new Date(date),
|
|
106
106
|
metric: groupByMetricRows[date]?.[0]?.[metricId]?.value.raw ?? null,
|
|
@@ -108,17 +108,17 @@ const getMetricExplorerDataPoints = (dimension, metric, metricRows) => {
|
|
|
108
108
|
}));
|
|
109
109
|
};
|
|
110
110
|
exports.getMetricExplorerDataPoints = getMetricExplorerDataPoints;
|
|
111
|
-
const getMetricExplorerDataPointsWithCompare = (dimension, metric, metricRows, compareMetricRows, comparison) => {
|
|
111
|
+
const getMetricExplorerDataPointsWithCompare = (dimension, compareDimension, metric, metricRows, compareMetricRows, comparison) => {
|
|
112
112
|
if (comparison.type === metricsExplorer_1.MetricExplorerComparison.NONE) {
|
|
113
113
|
throw new Error('Comparison type is required');
|
|
114
114
|
}
|
|
115
|
-
const dimensionId = (0, item_1.getItemId)(dimension);
|
|
116
115
|
const metricId = (0, item_1.getItemId)(metric);
|
|
117
|
-
const
|
|
118
|
-
const
|
|
119
|
-
const
|
|
116
|
+
const dimensionId = (0, item_1.getItemId)(dimension);
|
|
117
|
+
const compareDimensionId = (0, item_1.getItemId)(compareDimension);
|
|
118
|
+
const groupByMetricRows = (0, lodash_1.groupBy)(metricRows, (row) => new Date(String(row[dimensionId].value.raw)).toISOString());
|
|
119
|
+
const groupByCompareMetricRows = (0, lodash_1.groupBy)(compareMetricRows, (row) => new Date(String(row[compareDimensionId].value.raw)).toISOString());
|
|
120
120
|
const offsetGroupByCompareMetricRows = (0, lodash_1.mapKeys)(groupByCompareMetricRows, (_, date) => comparison.type === metricsExplorer_1.MetricExplorerComparison.PREVIOUS_PERIOD
|
|
121
|
-
? (0, exports.oneYearForward)(new Date(date)).
|
|
121
|
+
? (0, exports.oneYearForward)(new Date(date)).toISOString()
|
|
122
122
|
: date);
|
|
123
123
|
const dates = new Set([
|
|
124
124
|
...Object.keys(groupByMetricRows),
|