@quillsql/react 2.13.21 → 2.13.22
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/cjs/Chart.d.ts.map +1 -1
- package/dist/cjs/Chart.js +63 -43
- package/dist/cjs/Context.js +2 -2
- package/dist/cjs/Dashboard.d.ts.map +1 -1
- package/dist/cjs/Dashboard.js +58 -13
- package/dist/cjs/components/Chart/LineChart.d.ts.map +1 -1
- package/dist/cjs/components/Chart/LineChart.js +12 -22
- package/dist/cjs/components/Dashboard/DashboardFilter.d.ts.map +1 -1
- package/dist/cjs/components/Dashboard/DashboardFilter.js +6 -6
- package/dist/cjs/components/Dashboard/DataLoader.d.ts.map +1 -1
- package/dist/cjs/components/Dashboard/DataLoader.js +22 -10
- package/dist/cjs/hooks/useDashboard.d.ts +1 -4
- package/dist/cjs/hooks/useDashboard.d.ts.map +1 -1
- package/dist/cjs/hooks/useDashboard.js +1 -22
- package/dist/cjs/hooks/useExport.d.ts +1 -8
- package/dist/cjs/hooks/useExport.d.ts.map +1 -1
- package/dist/cjs/hooks/useExport.js +6 -4
- package/dist/cjs/hooks/useQuill.d.ts.map +1 -1
- package/dist/cjs/hooks/useQuill.js +4 -2
- package/dist/cjs/hooks/useReport.d.ts +12 -0
- package/dist/cjs/hooks/useReport.d.ts.map +1 -0
- package/dist/cjs/hooks/useReport.js +56 -0
- package/dist/cjs/index.d.ts +2 -1
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +3 -2
- package/dist/cjs/internals/ReportBuilder/PivotModal.d.ts.map +1 -1
- package/dist/cjs/internals/ReportBuilder/PivotModal.js +1 -0
- package/dist/cjs/utils/dataProcessing.js +2 -2
- package/dist/cjs/utils/filterProcessing.d.ts +2 -2
- package/dist/cjs/utils/filterProcessing.d.ts.map +1 -1
- package/dist/cjs/utils/filterProcessing.js +166 -36
- package/dist/cjs/utils/pivotConstructor.d.ts.map +1 -1
- package/dist/cjs/utils/pivotConstructor.js +47 -10
- package/dist/cjs/utils/queryConstructor.js +1 -1
- package/dist/cjs/utils/valueFormatter.d.ts +5 -1
- package/dist/cjs/utils/valueFormatter.d.ts.map +1 -1
- package/dist/cjs/utils/valueFormatter.js +32 -12
- package/dist/esm/Chart.d.ts.map +1 -1
- package/dist/esm/Chart.js +64 -44
- package/dist/esm/Context.js +2 -2
- package/dist/esm/Dashboard.d.ts.map +1 -1
- package/dist/esm/Dashboard.js +61 -16
- package/dist/esm/components/Chart/LineChart.d.ts.map +1 -1
- package/dist/esm/components/Chart/LineChart.js +15 -25
- package/dist/esm/components/Dashboard/DashboardFilter.d.ts.map +1 -1
- package/dist/esm/components/Dashboard/DashboardFilter.js +7 -7
- package/dist/esm/components/Dashboard/DataLoader.d.ts.map +1 -1
- package/dist/esm/components/Dashboard/DataLoader.js +22 -10
- package/dist/esm/hooks/useDashboard.d.ts +1 -4
- package/dist/esm/hooks/useDashboard.d.ts.map +1 -1
- package/dist/esm/hooks/useDashboard.js +1 -21
- package/dist/esm/hooks/useExport.d.ts +1 -8
- package/dist/esm/hooks/useExport.d.ts.map +1 -1
- package/dist/esm/hooks/useExport.js +6 -4
- package/dist/esm/hooks/useQuill.d.ts.map +1 -1
- package/dist/esm/hooks/useQuill.js +4 -2
- package/dist/esm/hooks/useReport.d.ts +12 -0
- package/dist/esm/hooks/useReport.d.ts.map +1 -0
- package/dist/esm/hooks/useReport.js +51 -0
- package/dist/esm/index.d.ts +2 -1
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +2 -1
- package/dist/esm/internals/ReportBuilder/PivotModal.d.ts.map +1 -1
- package/dist/esm/internals/ReportBuilder/PivotModal.js +1 -0
- package/dist/esm/utils/dataProcessing.js +2 -2
- package/dist/esm/utils/filterProcessing.d.ts +2 -2
- package/dist/esm/utils/filterProcessing.d.ts.map +1 -1
- package/dist/esm/utils/filterProcessing.js +166 -36
- package/dist/esm/utils/pivotConstructor.d.ts.map +1 -1
- package/dist/esm/utils/pivotConstructor.js +47 -10
- package/dist/esm/utils/queryConstructor.js +1 -1
- package/dist/esm/utils/valueFormatter.d.ts +5 -1
- package/dist/esm/utils/valueFormatter.d.ts.map +1 -1
- package/dist/esm/utils/valueFormatter.js +33 -13
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PivotModal.d.ts","sourceRoot":"","sources":["../../../../src/internals/ReportBuilder/PivotModal.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAOZ,SAAS,EACV,MAAM,OAAO,CAAC;AAuBf,OAAO,EACL,oBAAoB,EAKrB,MAAM,+BAA+B,CAAC;AAcvC,OAAO,EAAU,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC9D,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAG7C,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAM1D,MAAM,WAAW,eAAe;IAC9B,aAAa,EAAE,GAAG,CAAC;IACnB,gBAAgB,EAAE,GAAG,CAAC;IACtB,gBAAgB,EAAE,GAAG,CAAC;IACtB,mBAAmB,EAAE,GAAG,CAAC;IACzB,eAAe,EAAE,GAAG,CAAC;IACrB,kBAAkB,EAAE,GAAG,CAAC;IACxB,gBAAgB,EAAE,GAAG,CAAC;IACtB,mBAAmB,EAAE,GAAG,CAAC;IACzB,gBAAgB,EAAE,GAAG,CAAC;IACtB,mBAAmB,EAAE,GAAG,CAAC;IACzB,UAAU,EAAE,GAAG,CAAC;IAChB,aAAa,EAAE,GAAG,CAAC;IACnB,aAAa,EAAE,GAAG,CAAC;IACnB,eAAe,EAAE,GAAG,CAAC;IACrB,eAAe,EAAE,GAAG,CAAC;IACrB,aAAa,EAAE,GAAG,CAAC;IACnB,wBAAwB,EAAE,CAAC,KAAK,EAAE,oBAAoB,KAAK,GAAG,CAAC,OAAO,CAAC;IACvE,gBAAgB,EAAE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EACvC,KAAK,EACL,QAAa,EACb,UAAU,EACV,MAAM,EACN,MAAM,EACN,YAAY,GACb,EAAE;IACD,KAAK,EAAE,KAAK,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,GAAG,CAAC;IACb,MAAM,CAAC,EAAE,GAAG,CAAC;IACb,YAAY,CAAC,EAAE,GAAG,CAAC;CACpB;;;GAwBA;AAED,wBAAgB,0BAA0B,CACxC,KAAK,EAAE,KAAK,EACZ,IAAI,EAAE,GAAG,EAAE,EACX,SAAS,EAAE;IAAE,KAAK,EAAE,IAAI,CAAC;IAAC,GAAG,EAAE,IAAI,CAAA;CAAE,GAAG,SAAS,EACjD,YAAY,EAAE,OAAO,EACrB,QAAQ,SAAK,EACb,SAAS,GAAE;IAAE,KAAK,EAAE,IAAI,CAAC;IAAC,GAAG,EAAE,IAAI,CAAA;CAAE,GAAG,SAAqB,EAC7D,UAAU,CAAC,EAAE,MAAM,EACnB,YAAY,CAAC,EAAE,GAAG;;;;;;EA8enB"}
|
|
@@ -93,8 +93,8 @@ export const getPointToPointPercentageChange = (data) => {
|
|
|
93
93
|
start: minDate,
|
|
94
94
|
end: maxDate,
|
|
95
95
|
});
|
|
96
|
-
const minDateBucket = getDateString(minDate.toISOString()
|
|
97
|
-
const maxDateBucket = getDateString(maxDate.toISOString()
|
|
96
|
+
const minDateBucket = getDateString(minDate.toISOString(), undefined, dateBucket);
|
|
97
|
+
const maxDateBucket = getDateString(maxDate.toISOString(), undefined, dateBucket);
|
|
98
98
|
const minDateRows = data.rows.filter((row) => {
|
|
99
99
|
const rowValue = row[dateField];
|
|
100
100
|
if (rowValue) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FieldType, InternalFilter,
|
|
1
|
+
import { FieldType, InternalFilter, DashboardDateFilter, Filter, DashboardFilter } from '../models/Filter';
|
|
2
2
|
import { QuillReport } from '../models/Report';
|
|
3
3
|
import { UniqueValuesByColumn } from '../models/Tables';
|
|
4
4
|
import { FilterTreeNode } from './astFilterProcessing';
|
|
@@ -27,8 +27,8 @@ export declare function buildQueryFromFilters(baseAst: any, filters: FilterTreeN
|
|
|
27
27
|
query?: string;
|
|
28
28
|
error?: string;
|
|
29
29
|
}>;
|
|
30
|
-
export declare function mergeCustomFilters(filters: DashboardFilter[], customFilters: InternalFilter[]): any[];
|
|
31
30
|
export declare function applyCustomFilterToDashDateFilter(customDateFilter: Filter, dashboardDateFilter: DashboardDateFilter): DashboardDateFilter;
|
|
31
|
+
export declare function mergeCustomFilters(filters: DashboardFilter[], customFilters: InternalFilter[]): any[];
|
|
32
32
|
export declare function filtersAreEquivalent(filters1?: InternalFilter[], filters2?: InternalFilter[]): boolean;
|
|
33
33
|
/**
|
|
34
34
|
* Helper function that converts a UniqueValuesByColumn interface to a string map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filterProcessing.d.ts","sourceRoot":"","sources":["../../../src/utils/filterProcessing.ts"],"names":[],"mappings":"AAQA,OAAO,EAEL,SAAS,EACT,cAAc,
|
|
1
|
+
{"version":3,"file":"filterProcessing.d.ts","sourceRoot":"","sources":["../../../src/utils/filterProcessing.ts"],"names":[],"mappings":"AAQA,OAAO,EAEL,SAAS,EACT,cAAc,EAGd,mBAAmB,EACnB,MAAM,EAEN,eAAe,EAChB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,EAAE,cAAc,EAAmB,MAAM,uBAAuB,CAAC;AAGxE,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,GAAG,EAAE,GAAG,GAAG,CAoB5D;AAMD,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,GAAG,OAkBnD;AAED,wBAAgB,YAAY,CAC1B,MAAM,EAAE,GAAG,EACX,KAAK,EAAE,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,GAAG,SAqDpD,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { endOfDay, parse, startOfDay, sub } from 'date-fns';
|
|
1
2
|
import { COMPARISON_RANGE, PRIMARY_RANGE, defaultOptionsV2, getRangeFromPresetOptions, } from '../DateRangePicker/dateRangePickerUtils';
|
|
2
|
-
|
|
3
|
-
import { DateOperator, FieldType, FilterType, DashboardFilterType, } from '../models/Filter';
|
|
3
|
+
import { DateOperator, FieldType, FilterType, DashboardFilterType, TimeUnit, } from '../models/Filter';
|
|
4
4
|
import { filterTreeToAst } from './astFilterProcessing';
|
|
5
5
|
import { snakeAndCamelCaseToTitleCase } from './textProcessing';
|
|
6
6
|
export function findAndProcessDateFilter(filters) {
|
|
@@ -331,41 +331,9 @@ export async function buildQueryFromFilters(baseAst, filters, endpoint, client)
|
|
|
331
331
|
return { success: false, error: `error: ${error.message}` };
|
|
332
332
|
}
|
|
333
333
|
}
|
|
334
|
-
export function mergeCustomFilters(filters, customFilters) {
|
|
335
|
-
const customDateFilters = customFilters.filter((filter) => filter.filterType === FilterType.DateCustomFilter);
|
|
336
|
-
if (customDateFilters.length === 0) {
|
|
337
|
-
return filters.concat(customFilters);
|
|
338
|
-
}
|
|
339
|
-
const withoutDate = filters.filter((filter) => filter.filterType !== DashboardFilterType.Date);
|
|
340
|
-
const customWithoutDate = customFilters.filter((filter) => filter.filterType !== FilterType.DateCustomFilter);
|
|
341
|
-
const startDate = customDateFilters[0]?.value.startDate;
|
|
342
|
-
const endDate = customDateFilters[0]?.value.endDate;
|
|
343
|
-
return withoutDate
|
|
344
|
-
.concat([
|
|
345
|
-
{
|
|
346
|
-
filterType: DashboardFilterType.Date,
|
|
347
|
-
label: 'Date',
|
|
348
|
-
field: customDateFilters[0].field,
|
|
349
|
-
table: customDateFilters[0].table,
|
|
350
|
-
options: undefined,
|
|
351
|
-
primaryRange: {
|
|
352
|
-
label: 'Custom',
|
|
353
|
-
value: 'custom',
|
|
354
|
-
},
|
|
355
|
-
dashboardName: 'none',
|
|
356
|
-
presetRanges: [],
|
|
357
|
-
preset: {
|
|
358
|
-
label: 'Custom',
|
|
359
|
-
value: 'custom',
|
|
360
|
-
},
|
|
361
|
-
startDate: new Date(startDate),
|
|
362
|
-
endDate: new Date(endDate),
|
|
363
|
-
},
|
|
364
|
-
])
|
|
365
|
-
.concat(customWithoutDate);
|
|
366
|
-
}
|
|
367
334
|
export function applyCustomFilterToDashDateFilter(customDateFilter, dashboardDateFilter) {
|
|
368
|
-
if (customDateFilter.
|
|
335
|
+
if (customDateFilter.filterType === FilterType.DateCustomFilter &&
|
|
336
|
+
customDateFilter.value &&
|
|
369
337
|
typeof customDateFilter.value === 'object' &&
|
|
370
338
|
'startDate' in customDateFilter.value &&
|
|
371
339
|
'endDate' in customDateFilter.value) {
|
|
@@ -377,8 +345,170 @@ export function applyCustomFilterToDashDateFilter(customDateFilter, dashboardDat
|
|
|
377
345
|
endDate: new Date(endDate),
|
|
378
346
|
};
|
|
379
347
|
}
|
|
348
|
+
else if (customDateFilter.filterType === FilterType.DateFilter &&
|
|
349
|
+
customDateFilter.value &&
|
|
350
|
+
typeof customDateFilter.value === 'object' &&
|
|
351
|
+
'value' in customDateFilter.value &&
|
|
352
|
+
'unit' in customDateFilter.value) {
|
|
353
|
+
const { value, unit } = customDateFilter.value;
|
|
354
|
+
let processedUnit;
|
|
355
|
+
let processedValue = value;
|
|
356
|
+
switch (unit) {
|
|
357
|
+
case TimeUnit.Day:
|
|
358
|
+
processedUnit = 'days';
|
|
359
|
+
break;
|
|
360
|
+
case TimeUnit.Week:
|
|
361
|
+
processedUnit = 'weeks';
|
|
362
|
+
break;
|
|
363
|
+
case TimeUnit.Month:
|
|
364
|
+
processedUnit = 'months';
|
|
365
|
+
break;
|
|
366
|
+
case TimeUnit.Year:
|
|
367
|
+
processedUnit = 'years';
|
|
368
|
+
break;
|
|
369
|
+
case TimeUnit.Hour:
|
|
370
|
+
processedUnit = 'hours';
|
|
371
|
+
break;
|
|
372
|
+
case TimeUnit.Quarter:
|
|
373
|
+
processedUnit = 'months';
|
|
374
|
+
processedValue *= 3;
|
|
375
|
+
break;
|
|
376
|
+
}
|
|
377
|
+
switch (customDateFilter.operator) {
|
|
378
|
+
case DateOperator.InTheLast:
|
|
379
|
+
return {
|
|
380
|
+
...dashboardDateFilter,
|
|
381
|
+
startDate: sub(new Date(), { [processedUnit]: processedValue }),
|
|
382
|
+
endDate: new Date(),
|
|
383
|
+
};
|
|
384
|
+
// This represents the previous period compared to the current period.
|
|
385
|
+
// For instance, if the current period is the last 30 days, the previous period would be the 30 days before that.
|
|
386
|
+
case DateOperator.InThePrevious:
|
|
387
|
+
return {
|
|
388
|
+
...dashboardDateFilter,
|
|
389
|
+
startDate: sub(new Date(), { [processedUnit]: processedValue * 2 }),
|
|
390
|
+
endDate: sub(new Date(), { [processedUnit]: processedValue }),
|
|
391
|
+
};
|
|
392
|
+
// This represents the current period, and value is always 0.
|
|
393
|
+
// For instance if today was the 5th of August, the current month would be from the 1st to the 5th of August.
|
|
394
|
+
case DateOperator.InTheCurrent:
|
|
395
|
+
switch (unit) {
|
|
396
|
+
case TimeUnit.Day:
|
|
397
|
+
return {
|
|
398
|
+
...dashboardDateFilter,
|
|
399
|
+
startDate: startOfDay(new Date()),
|
|
400
|
+
endDate: endOfDay(new Date()),
|
|
401
|
+
};
|
|
402
|
+
case TimeUnit.Week:
|
|
403
|
+
return {
|
|
404
|
+
...dashboardDateFilter,
|
|
405
|
+
startDate: sub(new Date(), { days: new Date().getDay() }),
|
|
406
|
+
endDate: new Date(),
|
|
407
|
+
};
|
|
408
|
+
case TimeUnit.Month:
|
|
409
|
+
return {
|
|
410
|
+
...dashboardDateFilter,
|
|
411
|
+
startDate: new Date(new Date().getFullYear(), new Date().getMonth(), 1),
|
|
412
|
+
endDate: new Date(),
|
|
413
|
+
};
|
|
414
|
+
case TimeUnit.Year:
|
|
415
|
+
return {
|
|
416
|
+
...dashboardDateFilter,
|
|
417
|
+
startDate: new Date(new Date().getFullYear(), 0, 1),
|
|
418
|
+
endDate: new Date(),
|
|
419
|
+
};
|
|
420
|
+
case TimeUnit.Quarter:
|
|
421
|
+
return {
|
|
422
|
+
...dashboardDateFilter,
|
|
423
|
+
startDate: new Date(new Date().getFullYear(), Math.floor(new Date().getMonth() / 3) * 3, 1),
|
|
424
|
+
endDate: new Date(),
|
|
425
|
+
};
|
|
426
|
+
case TimeUnit.Hour:
|
|
427
|
+
return {
|
|
428
|
+
...dashboardDateFilter,
|
|
429
|
+
startDate: new Date(new Date().getFullYear(), new Date().getMonth(), new Date().getDate(), new Date().getHours()),
|
|
430
|
+
endDate: new Date(),
|
|
431
|
+
};
|
|
432
|
+
}
|
|
433
|
+
break;
|
|
434
|
+
default:
|
|
435
|
+
return dashboardDateFilter;
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
else if (customDateFilter.filterType === FilterType.DateComparisonFilter &&
|
|
439
|
+
customDateFilter.value &&
|
|
440
|
+
typeof customDateFilter.value === 'string') {
|
|
441
|
+
const parsedDate = parse(customDateFilter.value, 'yyyy-mm-dd', new Date());
|
|
442
|
+
switch (customDateFilter.operator) {
|
|
443
|
+
case DateOperator.GreaterThanOrEqualTo:
|
|
444
|
+
return {
|
|
445
|
+
...dashboardDateFilter,
|
|
446
|
+
startDate: parsedDate,
|
|
447
|
+
endDate: undefined,
|
|
448
|
+
};
|
|
449
|
+
case DateOperator.LessThanOrEqualTo:
|
|
450
|
+
return {
|
|
451
|
+
...dashboardDateFilter,
|
|
452
|
+
startDate: undefined,
|
|
453
|
+
endDate: parsedDate,
|
|
454
|
+
};
|
|
455
|
+
case DateOperator.LessThan:
|
|
456
|
+
return {
|
|
457
|
+
...dashboardDateFilter,
|
|
458
|
+
startDate: undefined,
|
|
459
|
+
endDate: sub(parsedDate, { days: 1 }),
|
|
460
|
+
};
|
|
461
|
+
case DateOperator.GreaterThan:
|
|
462
|
+
return {
|
|
463
|
+
...dashboardDateFilter,
|
|
464
|
+
startDate: sub(parsedDate, { days: 1 }),
|
|
465
|
+
endDate: undefined,
|
|
466
|
+
};
|
|
467
|
+
case DateOperator.EqualTo:
|
|
468
|
+
return {
|
|
469
|
+
...dashboardDateFilter,
|
|
470
|
+
startDate: parsedDate,
|
|
471
|
+
endDate: parsedDate,
|
|
472
|
+
};
|
|
473
|
+
default: return dashboardDateFilter;
|
|
474
|
+
}
|
|
475
|
+
}
|
|
380
476
|
return dashboardDateFilter;
|
|
381
477
|
}
|
|
478
|
+
export function mergeCustomFilters(filters, customFilters) {
|
|
479
|
+
const customDateFilters = customFilters.filter((filter) => filter.filterType === FilterType.DateCustomFilter || filter.filterType === FilterType.DateFilter || filter.filterType === FilterType.DateComparisonFilter);
|
|
480
|
+
if (customDateFilters.length === 0) {
|
|
481
|
+
return filters.concat(customFilters);
|
|
482
|
+
}
|
|
483
|
+
const withoutDate = filters.filter((filter) => filter.filterType !== DashboardFilterType.Date);
|
|
484
|
+
const customWithoutDate = customFilters.filter((filter) => filter.filterType !== FilterType.DateCustomFilter);
|
|
485
|
+
const withDate = filters.find((filter) => filter.filterType === DashboardFilterType.Date);
|
|
486
|
+
return withoutDate
|
|
487
|
+
.concat([
|
|
488
|
+
withDate
|
|
489
|
+
? applyCustomFilterToDashDateFilter(customDateFilters[0], withDate)
|
|
490
|
+
: {
|
|
491
|
+
filterType: DashboardFilterType.Date,
|
|
492
|
+
label: 'Date',
|
|
493
|
+
field: customDateFilters[0].field,
|
|
494
|
+
table: customDateFilters[0].table,
|
|
495
|
+
options: defaultOptionsV2,
|
|
496
|
+
primaryRange: {
|
|
497
|
+
label: 'Last 30 Days',
|
|
498
|
+
value: 'LAST_30_DAYS',
|
|
499
|
+
},
|
|
500
|
+
dashboardName: 'none',
|
|
501
|
+
presetRanges: defaultOptionsV2,
|
|
502
|
+
preset: {
|
|
503
|
+
label: 'Last 30 Days',
|
|
504
|
+
value: 'LAST_30_DAYS',
|
|
505
|
+
},
|
|
506
|
+
startDate: new Date(customDateFilters[0].value.startDate),
|
|
507
|
+
endDate: new Date(customDateFilters[0].value.endDate),
|
|
508
|
+
},
|
|
509
|
+
])
|
|
510
|
+
.concat(customWithoutDate);
|
|
511
|
+
}
|
|
382
512
|
export function filtersAreEquivalent(filters1, filters2) {
|
|
383
513
|
if (!filters1 && !filters2) {
|
|
384
514
|
return true;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pivotConstructor.d.ts","sourceRoot":"","sources":["../../../src/utils/pivotConstructor.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AACxC,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAQvD,wBAAsB,oBAAoB,CACxC,KAAK,EAAE,KAAK,EACZ,MAAM,EAAE,mBAAmB,EAC3B,MAAM,EAAE,mBAAmB,EAC3B,UAAU,CAAC,EAAE,MAAM,EACnB,UAAU,CAAC,EAAE,GAAG,EAChB,eAAe,CAAC,EAAE,GAAG,EACrB,QAAQ,CAAC,EAAE,MAAM,GAChB,OAAO,CAAC;IAAE,IAAI,EAAE,GAAG,EAAE,CAAC;IAAC,OAAO,EAAE,GAAG,EAAE,CAAA;CAAE,CAAC,
|
|
1
|
+
{"version":3,"file":"pivotConstructor.d.ts","sourceRoot":"","sources":["../../../src/utils/pivotConstructor.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AACxC,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAQvD,wBAAsB,oBAAoB,CACxC,KAAK,EAAE,KAAK,EACZ,MAAM,EAAE,mBAAmB,EAC3B,MAAM,EAAE,mBAAmB,EAC3B,UAAU,CAAC,EAAE,MAAM,EACnB,UAAU,CAAC,EAAE,GAAG,EAChB,eAAe,CAAC,EAAE,GAAG,EACrB,QAAQ,CAAC,EAAE,MAAM,GAChB,OAAO,CAAC;IAAE,IAAI,EAAE,GAAG,EAAE,CAAC;IAAC,OAAO,EAAE,GAAG,EAAE,CAAA;CAAE,CAAC,CAgO1C"}
|
|
@@ -70,7 +70,9 @@ export async function generatePivotWithSQL(pivot, report, client, dateBucket, da
|
|
|
70
70
|
label: snakeCaseToTitleCase(processColumnName(field.name.replace('comparison_', 'comparison '))),
|
|
71
71
|
format: field.name === pivot.rowField
|
|
72
72
|
? 'string'
|
|
73
|
-
: (pivot.valueFieldType ?? '
|
|
73
|
+
: (pivot.valueFieldType ?? pivot.aggregationType === 'percentage')
|
|
74
|
+
? 'percentage'
|
|
75
|
+
: 'whole_number',
|
|
74
76
|
}))
|
|
75
77
|
.filter((field, index) => field.field !== 'comparison_' + pivot.rowField || index === 0)
|
|
76
78
|
.sort((a, b) => {
|
|
@@ -85,9 +87,26 @@ export async function generatePivotWithSQL(pivot, report, client, dateBucket, da
|
|
|
85
87
|
if (pivot.rowField &&
|
|
86
88
|
!['string', 'varchar'].includes(pivot.rowFieldType || '')) {
|
|
87
89
|
rows.forEach((row) => {
|
|
88
|
-
row
|
|
90
|
+
row.__quillRawDate = typeof row[pivot.rowField || ''] === 'object' // BigQuery
|
|
89
91
|
? row[pivot.rowField || ''].value
|
|
90
|
-
: row[pivot.rowField || '']
|
|
92
|
+
: row[pivot.rowField || ''];
|
|
93
|
+
let value = typeof row[pivot.rowField || ''] === 'object' // BigQuery
|
|
94
|
+
? row[pivot.rowField || ''].value
|
|
95
|
+
: row[pivot.rowField || ''];
|
|
96
|
+
if (dateBucket === 'week' && dateFilter) {
|
|
97
|
+
const rowDate = new Date(value);
|
|
98
|
+
// check if row value is within dateFilter, else push it to within the date filter
|
|
99
|
+
if (rowDate < dateFilter.startDate) {
|
|
100
|
+
value = dateFilter.startDate.toISOString();
|
|
101
|
+
}
|
|
102
|
+
else if (rowDate > dateFilter.endDate) {
|
|
103
|
+
value = dateFilter.endDate.toISOString();
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
const dateString = getDateString(value, dateFilter
|
|
107
|
+
? { start: dateFilter.startDate, end: dateFilter.endDate }
|
|
108
|
+
: undefined, dateBucket);
|
|
109
|
+
row[pivot.rowField || ''] = dateString;
|
|
91
110
|
});
|
|
92
111
|
// add a row for each date in the range that doesn't have a value
|
|
93
112
|
if (pivot.rowField &&
|
|
@@ -97,27 +116,38 @@ export async function generatePivotWithSQL(pivot, report, client, dateBucket, da
|
|
|
97
116
|
const dateSet = new Set(rows.map((row) => row[pivot.rowField || '']));
|
|
98
117
|
// create a loop that will go through each formatted date and add a row if it doesn't exist going to the current date
|
|
99
118
|
for (let date = dateFilter.startDate; date <= dateFilter.endDate; date = new Date(date.getTime() + 24 * 60 * 60 * 1000)) {
|
|
100
|
-
const formattedDate = getDateString(date.toISOString().
|
|
119
|
+
const formattedDate = getDateString(date.toISOString(), { start: dateFilter.startDate, end: dateFilter.endDate }, dateBucket);
|
|
101
120
|
if (!dateSet.has(formattedDate)) {
|
|
102
121
|
const newRow = {};
|
|
103
122
|
newRow[pivot.rowField] = formattedDate;
|
|
123
|
+
newRow.__quillRawDate = date.toISOString();
|
|
104
124
|
rows.push(newRow);
|
|
105
125
|
dateSet.add(formattedDate);
|
|
106
126
|
}
|
|
107
|
-
// order the rows by the date field
|
|
108
|
-
// rows.sort((a: any, b: any) => {
|
|
109
|
-
// return compareValues(a, b, pivot.rowField ?? '');
|
|
110
|
-
// });
|
|
111
127
|
}
|
|
112
128
|
}
|
|
129
|
+
// sort the rows by date
|
|
130
|
+
rows.sort((a, b) => {
|
|
131
|
+
if (a.__quillRawDate < b.__quillRawDate) {
|
|
132
|
+
return -1;
|
|
133
|
+
}
|
|
134
|
+
if (a.__quillRawDate > b.__quillRawDate) {
|
|
135
|
+
return 1;
|
|
136
|
+
}
|
|
137
|
+
return 0;
|
|
138
|
+
});
|
|
139
|
+
// remove the raw date field
|
|
140
|
+
// rows.forEach((row: any) => {
|
|
141
|
+
// delete row.__quillRawDate;
|
|
142
|
+
// });
|
|
113
143
|
}
|
|
114
144
|
if (pivot.sort) {
|
|
115
145
|
rows.sort((a, b) => {
|
|
116
146
|
if (pivot.sortDirection === 'ASC') {
|
|
117
|
-
return compareValues(a, b, pivot.sortField
|
|
147
|
+
return compareValues(a, b, pivot.sortField || '');
|
|
118
148
|
}
|
|
119
149
|
else {
|
|
120
|
-
return compareValues(b, a, pivot.sortField
|
|
150
|
+
return compareValues(b, a, pivot.sortField || '');
|
|
121
151
|
}
|
|
122
152
|
});
|
|
123
153
|
}
|
|
@@ -130,6 +160,13 @@ export async function generatePivotWithSQL(pivot, report, client, dateBucket, da
|
|
|
130
160
|
column.label = 'Count';
|
|
131
161
|
}
|
|
132
162
|
});
|
|
163
|
+
// If a numeric column field is not present add it with a value of 0
|
|
164
|
+
const numericColumns = columns?.filter((column) => column.format === 'whole_number' || column.format === 'percentage');
|
|
165
|
+
rows.forEach((row) => {
|
|
166
|
+
numericColumns?.forEach((column) => {
|
|
167
|
+
row[column.field] = row[column.field] ?? 0;
|
|
168
|
+
});
|
|
169
|
+
});
|
|
133
170
|
return {
|
|
134
171
|
rows: rows,
|
|
135
172
|
columns: columns ?? [],
|
|
@@ -571,5 +571,5 @@ function createAggregationValuePivot(pivot, itemQueries, databaseType, rowLimit)
|
|
|
571
571
|
quill_qt_agg AS (SELECT ${aggregationType}(${valueAlias}) as ${processColumnReference(`${valueField}`, databaseType)} FROM quill_alias)
|
|
572
572
|
${compareCTE} ${aliasCTE} ${compareAggregation}
|
|
573
573
|
SELECT * FROM quill_qt_agg qt
|
|
574
|
-
${joinQuery}${rowLimit ? ` LIMIT ${rowLimit}` : ''}`;
|
|
574
|
+
${joinQuery} ${rowLimit ? ` LIMIT ${rowLimit}` : ''}`;
|
|
575
575
|
}
|
|
@@ -7,13 +7,17 @@ type Props = {
|
|
|
7
7
|
value: any;
|
|
8
8
|
field: string | undefined | null;
|
|
9
9
|
fields: Field[];
|
|
10
|
+
dateRange?: {
|
|
11
|
+
start: Date;
|
|
12
|
+
end: Date;
|
|
13
|
+
};
|
|
10
14
|
};
|
|
11
15
|
export declare const DATE_FORMAT_TYPES: string[];
|
|
12
16
|
export declare const NUMBER_FORMAT_TYPES: string[];
|
|
13
17
|
/**
|
|
14
18
|
* Pretty-prints the given values to their nice-looking string form.
|
|
15
19
|
*/
|
|
16
|
-
export declare const valueFormatter: ({ value, field, fields }: Props) => string;
|
|
20
|
+
export declare const valueFormatter: ({ value, field, fields, dateRange, }: Props) => string;
|
|
17
21
|
export declare const quillFormat: ({ value, format, }: {
|
|
18
22
|
value: any;
|
|
19
23
|
format: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"valueFormatter.d.ts","sourceRoot":"","sources":["../../../src/utils/valueFormatter.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"valueFormatter.d.ts","sourceRoot":"","sources":["../../../src/utils/valueFormatter.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,MAAM,MAAM,KAAK,GAAG;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,UAAU,CAAC;CACpB,CAAC;AAEF,KAAK,KAAK,GAAG;IACX,KAAK,EAAE,GAAG,CAAC;IACX,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CAAC;IACjC,MAAM,EAAE,KAAK,EAAE,CAAC;IAChB,SAAS,CAAC,EAAE;QAAE,KAAK,EAAE,IAAI,CAAC;QAAC,GAAG,EAAE,IAAI,CAAA;KAAE,CAAC;CACxC,CAAC;AAEF,eAAO,MAAM,iBAAiB,UAQ7B,CAAC;AAEF,eAAO,MAAM,mBAAmB,UAO/B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,cAAc,yCAKxB,KAAK,KAAG,MA8CV,CAAC;AAEF,eAAO,MAAM,WAAW,uBAGrB;IACD,KAAK,EAAE,GAAG,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;CAChB,KAAG,MAkDH,CAAC;AA0OF,wBAAgB,YAAY,CAAC,UAAU,EAAE,MAAM,oBAG9C;AAED,eAAO,MAAM,aAAa,MACrB;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;CAAE,KACtB;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;CAAE,UACjB,MAAM,KACb,MAkDF,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { endOfWeek, format, getWeek, isValid, parse, startOfWeek, } from 'date-fns';
|
|
1
|
+
import { endOfWeek, format, getWeek, isAfter, isBefore, isValid, parse, parseISO, startOfWeek, } from 'date-fns';
|
|
2
2
|
import { utcToZonedTime } from 'date-fns-tz';
|
|
3
3
|
export const DATE_FORMAT_TYPES = [
|
|
4
4
|
'yyyy',
|
|
@@ -20,7 +20,7 @@ export const NUMBER_FORMAT_TYPES = [
|
|
|
20
20
|
/**
|
|
21
21
|
* Pretty-prints the given values to their nice-looking string form.
|
|
22
22
|
*/
|
|
23
|
-
export const valueFormatter = ({ value, field, fields }) => {
|
|
23
|
+
export const valueFormatter = ({ value, field, fields, dateRange, }) => {
|
|
24
24
|
if (field === undefined || field === null)
|
|
25
25
|
return '';
|
|
26
26
|
if (value === undefined || value === null)
|
|
@@ -47,7 +47,7 @@ export const valueFormatter = ({ value, field, fields }) => {
|
|
|
47
47
|
case 'yyyy':
|
|
48
48
|
return format_YYYY(value);
|
|
49
49
|
case 'MMM_dd':
|
|
50
|
-
return
|
|
50
|
+
return format_MMM_d(value);
|
|
51
51
|
case 'MMM_yyyy':
|
|
52
52
|
return format_MMM_yyyy(value);
|
|
53
53
|
case 'MMM_dd_yyyy':
|
|
@@ -58,7 +58,7 @@ export const valueFormatter = ({ value, field, fields }) => {
|
|
|
58
58
|
case 'hh_ap_pm':
|
|
59
59
|
return format_hh_ap_pm(value);
|
|
60
60
|
case 'MMM_dd-MMM_dd':
|
|
61
|
-
return
|
|
61
|
+
return format_MMM_d_MMM_d(value, dateRange);
|
|
62
62
|
case 'MMM_dd_hh:mm_ap_pm':
|
|
63
63
|
return format_MMM_dd_hh_mm_ap_pm(value);
|
|
64
64
|
case 'wo, yyyy':
|
|
@@ -92,8 +92,9 @@ export const quillFormat = ({ value, format, }) => {
|
|
|
92
92
|
return formatString(value);
|
|
93
93
|
case 'yyyy':
|
|
94
94
|
return format_YYYY(value);
|
|
95
|
+
case 'MMM_d':
|
|
95
96
|
case 'MMM_dd':
|
|
96
|
-
return
|
|
97
|
+
return format_MMM_d(value);
|
|
97
98
|
case 'MMM_yyyy':
|
|
98
99
|
return format_MMM_yyyy(value);
|
|
99
100
|
case 'MMM_dd_yyyy':
|
|
@@ -103,8 +104,9 @@ export const quillFormat = ({ value, format, }) => {
|
|
|
103
104
|
// return format_MMM_ww_yyyy(value);
|
|
104
105
|
case 'hh_ap_pm':
|
|
105
106
|
return format_hh_ap_pm(value);
|
|
107
|
+
case 'MMM_d-MMM_d':
|
|
106
108
|
case 'MMM_dd-MMM_dd':
|
|
107
|
-
return
|
|
109
|
+
return format_MMM_d_MMM_d(value);
|
|
108
110
|
case 'MMM_dd_hh:mm_ap_pm':
|
|
109
111
|
return format_MMM_dd_hh_mm_ap_pm(value);
|
|
110
112
|
case 'wo, yyyy':
|
|
@@ -226,22 +228,40 @@ const _getUTCDateHelper = (value, fmt) => {
|
|
|
226
228
|
const format_YYYY = (value) => _getUTCDateHelper(value, 'yyyy');
|
|
227
229
|
const format_MMM_yyyy = (value) => _getUTCDateHelper(value, 'MMM yyyy');
|
|
228
230
|
const format_hh_ap_pm = (value) => _getUTCDateHelper(value, 'hh:mm aa');
|
|
229
|
-
const
|
|
231
|
+
const format_MMM_d = (value) => _getUTCDateHelper(value, 'MMM d');
|
|
230
232
|
const format_MMM_dd_yyyy = (value) => {
|
|
231
233
|
return _getUTCDateHelper(value, 'dd MMM yyyy');
|
|
232
234
|
};
|
|
233
|
-
const
|
|
234
|
-
const utcDate =
|
|
235
|
+
const format_MMM_d_MMM_d = (value, dateRange) => {
|
|
236
|
+
const utcDate = parseISO(value.split('T')[0]);
|
|
235
237
|
if (!isValid(utcDate))
|
|
236
238
|
return 'Invalid date';
|
|
237
|
-
|
|
238
|
-
|
|
239
|
+
let monday = startOfWeek(utcDate, { weekStartsOn: 1 });
|
|
240
|
+
let sunday = endOfWeek(utcDate, { weekStartsOn: 1 });
|
|
241
|
+
// If date range is provided, adjust the start and end dates
|
|
242
|
+
if (dateRange && dateRange.start && dateRange.end) {
|
|
243
|
+
const utcStartString = dateRange.start.toISOString().split('T')[0];
|
|
244
|
+
const utcEndString = dateRange.end.toISOString().split('T')[0];
|
|
245
|
+
if (utcStartString && utcEndString) {
|
|
246
|
+
const utcStart = parseISO(utcStartString);
|
|
247
|
+
const utcEnd = parseISO(utcEndString);
|
|
248
|
+
if (isBefore(monday, utcStart)) {
|
|
249
|
+
monday = utcStart;
|
|
250
|
+
}
|
|
251
|
+
if (isAfter(sunday, utcEnd)) {
|
|
252
|
+
sunday = utcEnd;
|
|
253
|
+
}
|
|
254
|
+
if (isAfter(monday, utcEnd) || isBefore(sunday, utcStart)) {
|
|
255
|
+
return 'Date outside range';
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
}
|
|
239
259
|
// Check if start and end are in the same month
|
|
240
260
|
if (format(monday, 'MMM') === format(sunday, 'MMM')) {
|
|
241
|
-
return `${format(monday, 'MMM
|
|
261
|
+
return `${format(monday, 'MMM d')} - ${format(sunday, 'd')}`;
|
|
242
262
|
}
|
|
243
263
|
else {
|
|
244
|
-
return `${format(monday, 'MMM
|
|
264
|
+
return `${format(monday, 'MMM d')} - ${format(sunday, 'MMM d')}`;
|
|
245
265
|
}
|
|
246
266
|
};
|
|
247
267
|
const format_MMM_dd_hh_mm_ap_pm = (value) => {
|