@quillsql/react 2.16.69 → 2.16.70
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 +52 -32
- package/dist/index.d.cts +8 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +52 -32
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -17307,10 +17307,15 @@ async function generatePivotWithSQL({
|
|
|
17307
17307
|
const queryResponseFields = resp.data?.fields || resp.queries?.queryResults?.[0]?.fields || [];
|
|
17308
17308
|
const rowCount = resp.queries?.queryResults?.[1]?.rows?.[0]?.row_count || 0;
|
|
17309
17309
|
parseValueFromBigQueryDates(queryResponseRows, queryResponseFields);
|
|
17310
|
+
const resultRowField = processColumnName(
|
|
17311
|
+
String(
|
|
17312
|
+
resp.data?.config?.rowField ?? pivot.rowField ?? ""
|
|
17313
|
+
)
|
|
17314
|
+
);
|
|
17310
17315
|
const responseRows = queryResponseRows;
|
|
17311
17316
|
const responseFields = queryResponseFields;
|
|
17312
|
-
const rows =
|
|
17313
|
-
(row) => !row[
|
|
17317
|
+
const rows = resultRowField ? responseRows.map(
|
|
17318
|
+
(row) => !row[resultRowField] ? { ...row, [resultRowField]: "-" } : row
|
|
17314
17319
|
) : responseRows;
|
|
17315
17320
|
if (pivot.columnField && client.databaseType?.toLowerCase() === "bigquery") {
|
|
17316
17321
|
rows.forEach((row) => {
|
|
@@ -17330,27 +17335,27 @@ async function generatePivotWithSQL({
|
|
|
17330
17335
|
(field.field || field.name).replace("comparison_", "comparison ")
|
|
17331
17336
|
)
|
|
17332
17337
|
),
|
|
17333
|
-
format: (field.field || field.name) ===
|
|
17338
|
+
format: processColumnName(field.field || field.name) === resultRowField ? "string" : pivot.aggregations?.find(
|
|
17334
17339
|
(agg) => agg.valueField === (field.field || field.name) || `${agg.valueField}_percentage` === (field.field || field.name) || !agg.valueField && agg.aggregationType === "percentage" && (field.field || field.name)?.endsWith("percentage")
|
|
17335
17340
|
)?.aggregationType === "percentage" ? "percent" : "whole_number",
|
|
17336
17341
|
fieldType: field.fieldType,
|
|
17337
17342
|
jsType: field.jsType,
|
|
17338
17343
|
dataTypeID: field.dataTypeID
|
|
17339
17344
|
})).filter(
|
|
17340
|
-
(field, index) => field.field !== "comparison_" +
|
|
17345
|
+
(field, index) => field.field !== "comparison_" + resultRowField || index === 0
|
|
17341
17346
|
).sort((a, b) => {
|
|
17342
|
-
if (a.field ===
|
|
17347
|
+
if (a.field === resultRowField) {
|
|
17343
17348
|
return -1;
|
|
17344
17349
|
}
|
|
17345
|
-
if (b.field ===
|
|
17350
|
+
if (b.field === resultRowField) {
|
|
17346
17351
|
return 1;
|
|
17347
17352
|
}
|
|
17348
17353
|
return 0;
|
|
17349
17354
|
});
|
|
17350
|
-
if (
|
|
17355
|
+
if (resultRowField && !isStringType(pivot.rowFieldType || "")) {
|
|
17351
17356
|
rows.forEach((row) => {
|
|
17352
|
-
row.__quillRawDate = typeof row[
|
|
17353
|
-
let value = typeof row[
|
|
17357
|
+
row.__quillRawDate = typeof row[resultRowField] === "object" ? row[resultRowField].value : row[resultRowField];
|
|
17358
|
+
let value = typeof row[resultRowField] === "object" ? row[resultRowField].value : row[resultRowField];
|
|
17354
17359
|
if (dateBucket === "week" && dateFilter?.startDate && dateFilter?.endDate) {
|
|
17355
17360
|
const rowDate = new Date(value);
|
|
17356
17361
|
if (rowDate < dateFilter.startDate) {
|
|
@@ -17365,12 +17370,10 @@ async function generatePivotWithSQL({
|
|
|
17365
17370
|
dateBucket,
|
|
17366
17371
|
databaseType
|
|
17367
17372
|
);
|
|
17368
|
-
row[
|
|
17373
|
+
row[resultRowField] = dateString;
|
|
17369
17374
|
});
|
|
17370
|
-
if (
|
|
17371
|
-
const dateSet = new Set(
|
|
17372
|
-
rows.map((row) => row[pivot.rowField || ""])
|
|
17373
|
-
);
|
|
17375
|
+
if (resultRowField && pivot.rowFieldType && !isStringType(pivot.rowFieldType) && dateFilter?.startDate && dateFilter?.endDate) {
|
|
17376
|
+
const dateSet = new Set(rows.map((row) => row[resultRowField]));
|
|
17374
17377
|
for (let date = dateFilter.startDate; date <= dateFilter.endDate; date = new Date(date.getTime() + 24 * 60 * 60 * 1e3)) {
|
|
17375
17378
|
const formattedDate = getDateString(
|
|
17376
17379
|
date.toISOString(),
|
|
@@ -17380,7 +17383,7 @@ async function generatePivotWithSQL({
|
|
|
17380
17383
|
);
|
|
17381
17384
|
if (!dateSet.has(formattedDate)) {
|
|
17382
17385
|
const newRow = {};
|
|
17383
|
-
newRow[
|
|
17386
|
+
newRow[resultRowField] = formattedDate;
|
|
17384
17387
|
newRow.__quillRawDate = date.toISOString();
|
|
17385
17388
|
rows.push(newRow);
|
|
17386
17389
|
dateSet.add(formattedDate);
|
|
@@ -17417,6 +17420,7 @@ async function generatePivotWithSQL({
|
|
|
17417
17420
|
rows,
|
|
17418
17421
|
columns: columns ?? [],
|
|
17419
17422
|
rowCount: rowCount || rows.length,
|
|
17423
|
+
rowField: resultRowField || void 0,
|
|
17420
17424
|
pivotQuery: report?.queryString || "",
|
|
17421
17425
|
comparisonPivotQuery: comparisonPivotQuery || ""
|
|
17422
17426
|
};
|
|
@@ -17516,14 +17520,18 @@ function processPivotData({
|
|
|
17516
17520
|
rows: responseRows,
|
|
17517
17521
|
fields: responseFields,
|
|
17518
17522
|
pivot,
|
|
17523
|
+
resultRowField,
|
|
17519
17524
|
dateBucket,
|
|
17520
17525
|
dateFilter,
|
|
17521
17526
|
client,
|
|
17522
17527
|
rowCount
|
|
17523
17528
|
}) {
|
|
17524
17529
|
const databaseType = client.databaseType || "postgresql";
|
|
17525
|
-
const
|
|
17526
|
-
(
|
|
17530
|
+
const pivotRowField = processColumnName(
|
|
17531
|
+
String(resultRowField ?? pivot.rowField ?? "")
|
|
17532
|
+
);
|
|
17533
|
+
const rows = pivotRowField ? responseRows.map(
|
|
17534
|
+
(row) => !row[pivotRowField] ? { ...row, [pivotRowField]: "-" } : row
|
|
17527
17535
|
) : responseRows;
|
|
17528
17536
|
if (pivot.columnField && client.databaseType?.toLowerCase() === "bigquery") {
|
|
17529
17537
|
rows.forEach((row) => {
|
|
@@ -17543,27 +17551,27 @@ function processPivotData({
|
|
|
17543
17551
|
(field.field || field.name).replace("comparison_", "comparison ")
|
|
17544
17552
|
)
|
|
17545
17553
|
),
|
|
17546
|
-
format: (field.field || field.name) ===
|
|
17554
|
+
format: processColumnName(field.field || field.name) === pivotRowField ? "string" : pivot.aggregations?.find(
|
|
17547
17555
|
(agg) => agg.valueField === (field.field || field.name) || `${agg.valueField}_percentage` === (field.field || field.name) || !agg.valueField && agg.aggregationType === "percentage" && (field.field || field.name)?.endsWith("percentage")
|
|
17548
17556
|
)?.aggregationType === "percentage" ? "percent" : "whole_number",
|
|
17549
17557
|
fieldType: field.fieldType,
|
|
17550
17558
|
jsType: field.jsType,
|
|
17551
17559
|
dataTypeID: field.dataTypeID
|
|
17552
17560
|
})).filter(
|
|
17553
|
-
(field, index) => field.field !== "comparison_" +
|
|
17561
|
+
(field, index) => field.field !== "comparison_" + pivotRowField || index === 0
|
|
17554
17562
|
).sort((a, b) => {
|
|
17555
|
-
if (a.field ===
|
|
17563
|
+
if (a.field === pivotRowField) {
|
|
17556
17564
|
return -1;
|
|
17557
17565
|
}
|
|
17558
|
-
if (b.field ===
|
|
17566
|
+
if (b.field === pivotRowField) {
|
|
17559
17567
|
return 1;
|
|
17560
17568
|
}
|
|
17561
17569
|
return 0;
|
|
17562
17570
|
});
|
|
17563
|
-
if (
|
|
17571
|
+
if (pivotRowField && !isStringType(pivot.rowFieldType || "")) {
|
|
17564
17572
|
rows.forEach((row) => {
|
|
17565
|
-
row.__quillRawDate = typeof row[
|
|
17566
|
-
let value = typeof row[
|
|
17573
|
+
row.__quillRawDate = typeof row[pivotRowField] === "object" ? row[pivotRowField].value : row[pivotRowField];
|
|
17574
|
+
let value = typeof row[pivotRowField] === "object" ? row[pivotRowField].value : row[pivotRowField];
|
|
17567
17575
|
if (dateBucket === "week" && dateFilter?.startDate && dateFilter?.endDate) {
|
|
17568
17576
|
const rowDate = new Date(value);
|
|
17569
17577
|
if (rowDate < dateFilter.startDate) {
|
|
@@ -17578,12 +17586,10 @@ function processPivotData({
|
|
|
17578
17586
|
dateBucket,
|
|
17579
17587
|
databaseType
|
|
17580
17588
|
);
|
|
17581
|
-
row[
|
|
17589
|
+
row[pivotRowField] = dateString;
|
|
17582
17590
|
});
|
|
17583
|
-
if (
|
|
17584
|
-
const dateSet = new Set(
|
|
17585
|
-
rows.map((row) => row[pivot.rowField || ""])
|
|
17586
|
-
);
|
|
17591
|
+
if (pivotRowField && pivot.rowFieldType && !isStringType(pivot.rowFieldType) && dateFilter?.startDate && dateFilter?.endDate) {
|
|
17592
|
+
const dateSet = new Set(rows.map((row) => row[pivotRowField]));
|
|
17587
17593
|
for (let date = dateFilter.startDate; date <= dateFilter.endDate; date = new Date(date.getTime() + 24 * 60 * 60 * 1e3)) {
|
|
17588
17594
|
const formattedDate = getDateString(
|
|
17589
17595
|
date.toISOString(),
|
|
@@ -17593,7 +17599,7 @@ function processPivotData({
|
|
|
17593
17599
|
);
|
|
17594
17600
|
if (!dateSet.has(formattedDate)) {
|
|
17595
17601
|
const newRow = {};
|
|
17596
|
-
newRow[
|
|
17602
|
+
newRow[pivotRowField] = formattedDate;
|
|
17597
17603
|
newRow.__quillRawDate = date.toISOString();
|
|
17598
17604
|
rows.push(newRow);
|
|
17599
17605
|
dateSet.add(formattedDate);
|
|
@@ -17630,6 +17636,7 @@ function processPivotData({
|
|
|
17630
17636
|
rows,
|
|
17631
17637
|
columns: columns ?? [],
|
|
17632
17638
|
rowCount: rowCount || rows.length,
|
|
17639
|
+
rowField: pivotRowField || void 0,
|
|
17633
17640
|
pivotQuery: "",
|
|
17634
17641
|
comparisonPivotQuery: ""
|
|
17635
17642
|
};
|
|
@@ -21989,12 +21996,14 @@ function buildPivotOnlyReportFromResponse({
|
|
|
21989
21996
|
}
|
|
21990
21997
|
let pivotRows = rawPivotRows;
|
|
21991
21998
|
let pivotColumns = Array.isArray(response?.pivotColumns) ? response.pivotColumns : fallbackBaseReport.pivotColumns ?? [];
|
|
21999
|
+
let pivotResultRowField;
|
|
21992
22000
|
let pivotRowCount = typeof response?.pivotRowCount === "number" ? response.pivotRowCount : typeof response?.rowCount === "number" ? response.rowCount : rawPivotRows.length;
|
|
21993
22001
|
if (effectivePivot && rawPivotFields.length > 0) {
|
|
21994
22002
|
const pivotData = processPivotData({
|
|
21995
22003
|
rows: rawPivotRows,
|
|
21996
22004
|
fields: rawPivotFields,
|
|
21997
22005
|
pivot: effectivePivot,
|
|
22006
|
+
resultRowField: response?.config?.rowField,
|
|
21998
22007
|
...effectivePivot.dateBucket ? { dateBucket: effectivePivot.dateBucket } : {},
|
|
21999
22008
|
client,
|
|
22000
22009
|
rowCount: typeof response?.rowCount === "number" ? response.rowCount : void 0
|
|
@@ -22002,6 +22011,7 @@ function buildPivotOnlyReportFromResponse({
|
|
|
22002
22011
|
pivotRows = pivotData.rows;
|
|
22003
22012
|
pivotColumns = pivotData.columns;
|
|
22004
22013
|
pivotRowCount = pivotData.rowCount;
|
|
22014
|
+
pivotResultRowField = pivotData.rowField;
|
|
22005
22015
|
}
|
|
22006
22016
|
const pivotOnlyReport = {
|
|
22007
22017
|
...responseReport,
|
|
@@ -22013,7 +22023,9 @@ function buildPivotOnlyReportFromResponse({
|
|
|
22013
22023
|
pivot: effectivePivot,
|
|
22014
22024
|
pivotRows,
|
|
22015
22025
|
pivotColumns,
|
|
22016
|
-
pivotRowCount
|
|
22026
|
+
pivotRowCount,
|
|
22027
|
+
pivotResultRowField,
|
|
22028
|
+
pivotResultSourceRowField: effectivePivot?.rowField
|
|
22017
22029
|
};
|
|
22018
22030
|
if (additionalProcessing) {
|
|
22019
22031
|
pivotOnlyReport.pagination = additionalProcessing.page;
|
|
@@ -63160,6 +63172,8 @@ async function loadViaReportBuilderState({
|
|
|
63160
63172
|
pivotRows: refreshedPivotData?.rows ?? compatibleReportPivotRows ?? (canReuseBasePivotRowsAndColumns ? baseReport.pivotRows : []) ?? [],
|
|
63161
63173
|
pivotColumns: refreshedPivotData?.columns ?? compatibleReportPivotColumns ?? (canReuseBasePivotRowsAndColumns ? baseReport.pivotColumns : []) ?? [],
|
|
63162
63174
|
pivotRowCount: refreshedPivotData?.rowCount ?? compatibleReportPivotRowCount ?? (canReuseBasePivotRowsAndColumns ? baseReport.pivotRowCount : void 0) ?? 0,
|
|
63175
|
+
pivotResultRowField: refreshedPivotData?.rowField ?? reportBuilderInfo.report.pivotResultRowField ?? (canReuseBasePivotRowsAndColumns ? baseReport.pivotResultRowField : void 0),
|
|
63176
|
+
pivotResultSourceRowField: refreshedPivotData?.rowField && requestedPivotRowField ? requestedPivotRowField : reportBuilderInfo.report.pivotResultSourceRowField ? reportBuilderInfo.report.pivotResultSourceRowField : canReuseBasePivotRowsAndColumns ? baseReport.pivotResultSourceRowField : void 0,
|
|
63163
63177
|
uniqueStringsByTable: reportBuilderInfo.uniqueStringsByTable,
|
|
63164
63178
|
uniqueStringsByColumn: reportBuilderInfo.uniqueStringsByColumn,
|
|
63165
63179
|
columnUniqueValues: reportBuilderInfo.uniqueStringsByColumn,
|
|
@@ -66199,6 +66213,8 @@ function useReport(reportIdArg, options = {}) {
|
|
|
66199
66213
|
pivotRows: mergedPivotRows,
|
|
66200
66214
|
pivotColumns: report.pivotColumns,
|
|
66201
66215
|
pivotRowCount: mergedPivotRowCount,
|
|
66216
|
+
pivotResultRowField: report.pivotResultRowField,
|
|
66217
|
+
pivotResultSourceRowField: report.pivotResultSourceRowField,
|
|
66202
66218
|
pivotQuery: report.pivotQuery,
|
|
66203
66219
|
comparisonPivotQuery: report.comparisonPivotQuery,
|
|
66204
66220
|
reportBuilderState: mergedReportBuilderState ? {
|
|
@@ -66218,7 +66234,11 @@ function useReport(reportIdArg, options = {}) {
|
|
|
66218
66234
|
const chartData = (0, import_react61.useMemo)(() => {
|
|
66219
66235
|
if (!sourceReport) return void 0;
|
|
66220
66236
|
const rowsForChart = Array.isArray(sourceReport.rows) ? sourceReport.rows : [];
|
|
66221
|
-
const
|
|
66237
|
+
const chartPivot = nextPivot ?? (!chartPivotHydratedFromSourceRef.current ? sourceReport.pivot ?? null : null);
|
|
66238
|
+
const chartPivotForDisplay = chartPivot && sourceReport.pivotResultRowField && sourceReport.pivotResultSourceRowField === chartPivot.rowField ? {
|
|
66239
|
+
...chartPivot,
|
|
66240
|
+
rowField: sourceReport.pivotResultRowField
|
|
66241
|
+
} : chartPivot;
|
|
66222
66242
|
const rowCountForChart = chartPivotForDisplay ? sourceReport.pivotRowCount ?? (Array.isArray(sourceReport.pivotRows) ? sourceReport.pivotRows.length : sourceReport.rowCount) : useInMemoryEngines ? rowsForChart.length : sourceReport.rowCount;
|
|
66223
66243
|
const referencedTablesForChart = effectiveReportBuilderState?.tables.map((table2) => table2.name).filter((name2) => Boolean(name2));
|
|
66224
66244
|
const pivotRowsForChart = Array.isArray(sourceReport.pivotRows) ? sourceReport.pivotRows : void 0;
|
package/dist/index.d.cts
CHANGED
|
@@ -620,6 +620,8 @@ type PivotData = {
|
|
|
620
620
|
rows: any[];
|
|
621
621
|
columns: ColumnInternal[];
|
|
622
622
|
rowCount: number;
|
|
623
|
+
/** Row field name returned by the pivot query after backend disambiguation. */
|
|
624
|
+
rowField?: string;
|
|
623
625
|
pivotQuery: string;
|
|
624
626
|
comparisonPivotQuery?: string;
|
|
625
627
|
};
|
|
@@ -791,6 +793,10 @@ interface QuillReport {
|
|
|
791
793
|
pivotRows?: {
|
|
792
794
|
[key: string]: string;
|
|
793
795
|
}[];
|
|
796
|
+
/** Row field name returned by the pivot query after backend disambiguation. */
|
|
797
|
+
pivotResultRowField?: string;
|
|
798
|
+
/** Logical row field used to request pivotResultRowField. */
|
|
799
|
+
pivotResultSourceRowField?: string;
|
|
794
800
|
/**
|
|
795
801
|
* A list of metadata about the pivot yAxes of this report.
|
|
796
802
|
*/
|
|
@@ -3192,6 +3198,8 @@ declare function useReport(reportIdArg?: string, options?: UseReportOptions): {
|
|
|
3192
3198
|
pivotRows?: {
|
|
3193
3199
|
[key: string]: string;
|
|
3194
3200
|
}[];
|
|
3201
|
+
pivotResultRowField?: string;
|
|
3202
|
+
pivotResultSourceRowField?: string;
|
|
3195
3203
|
pivotColumns?: ColumnInternal[];
|
|
3196
3204
|
pivotRowCount?: number;
|
|
3197
3205
|
} | undefined;
|
package/dist/index.d.ts
CHANGED
|
@@ -620,6 +620,8 @@ type PivotData = {
|
|
|
620
620
|
rows: any[];
|
|
621
621
|
columns: ColumnInternal[];
|
|
622
622
|
rowCount: number;
|
|
623
|
+
/** Row field name returned by the pivot query after backend disambiguation. */
|
|
624
|
+
rowField?: string;
|
|
623
625
|
pivotQuery: string;
|
|
624
626
|
comparisonPivotQuery?: string;
|
|
625
627
|
};
|
|
@@ -791,6 +793,10 @@ interface QuillReport {
|
|
|
791
793
|
pivotRows?: {
|
|
792
794
|
[key: string]: string;
|
|
793
795
|
}[];
|
|
796
|
+
/** Row field name returned by the pivot query after backend disambiguation. */
|
|
797
|
+
pivotResultRowField?: string;
|
|
798
|
+
/** Logical row field used to request pivotResultRowField. */
|
|
799
|
+
pivotResultSourceRowField?: string;
|
|
794
800
|
/**
|
|
795
801
|
* A list of metadata about the pivot yAxes of this report.
|
|
796
802
|
*/
|
|
@@ -3192,6 +3198,8 @@ declare function useReport(reportIdArg?: string, options?: UseReportOptions): {
|
|
|
3192
3198
|
pivotRows?: {
|
|
3193
3199
|
[key: string]: string;
|
|
3194
3200
|
}[];
|
|
3201
|
+
pivotResultRowField?: string;
|
|
3202
|
+
pivotResultSourceRowField?: string;
|
|
3195
3203
|
pivotColumns?: ColumnInternal[];
|
|
3196
3204
|
pivotRowCount?: number;
|
|
3197
3205
|
} | undefined;
|
package/dist/index.js
CHANGED
|
@@ -17353,10 +17353,15 @@ async function generatePivotWithSQL({
|
|
|
17353
17353
|
const queryResponseFields = resp.data?.fields || resp.queries?.queryResults?.[0]?.fields || [];
|
|
17354
17354
|
const rowCount = resp.queries?.queryResults?.[1]?.rows?.[0]?.row_count || 0;
|
|
17355
17355
|
parseValueFromBigQueryDates(queryResponseRows, queryResponseFields);
|
|
17356
|
+
const resultRowField = processColumnName(
|
|
17357
|
+
String(
|
|
17358
|
+
resp.data?.config?.rowField ?? pivot.rowField ?? ""
|
|
17359
|
+
)
|
|
17360
|
+
);
|
|
17356
17361
|
const responseRows = queryResponseRows;
|
|
17357
17362
|
const responseFields = queryResponseFields;
|
|
17358
|
-
const rows =
|
|
17359
|
-
(row) => !row[
|
|
17363
|
+
const rows = resultRowField ? responseRows.map(
|
|
17364
|
+
(row) => !row[resultRowField] ? { ...row, [resultRowField]: "-" } : row
|
|
17360
17365
|
) : responseRows;
|
|
17361
17366
|
if (pivot.columnField && client.databaseType?.toLowerCase() === "bigquery") {
|
|
17362
17367
|
rows.forEach((row) => {
|
|
@@ -17376,27 +17381,27 @@ async function generatePivotWithSQL({
|
|
|
17376
17381
|
(field.field || field.name).replace("comparison_", "comparison ")
|
|
17377
17382
|
)
|
|
17378
17383
|
),
|
|
17379
|
-
format: (field.field || field.name) ===
|
|
17384
|
+
format: processColumnName(field.field || field.name) === resultRowField ? "string" : pivot.aggregations?.find(
|
|
17380
17385
|
(agg) => agg.valueField === (field.field || field.name) || `${agg.valueField}_percentage` === (field.field || field.name) || !agg.valueField && agg.aggregationType === "percentage" && (field.field || field.name)?.endsWith("percentage")
|
|
17381
17386
|
)?.aggregationType === "percentage" ? "percent" : "whole_number",
|
|
17382
17387
|
fieldType: field.fieldType,
|
|
17383
17388
|
jsType: field.jsType,
|
|
17384
17389
|
dataTypeID: field.dataTypeID
|
|
17385
17390
|
})).filter(
|
|
17386
|
-
(field, index) => field.field !== "comparison_" +
|
|
17391
|
+
(field, index) => field.field !== "comparison_" + resultRowField || index === 0
|
|
17387
17392
|
).sort((a, b) => {
|
|
17388
|
-
if (a.field ===
|
|
17393
|
+
if (a.field === resultRowField) {
|
|
17389
17394
|
return -1;
|
|
17390
17395
|
}
|
|
17391
|
-
if (b.field ===
|
|
17396
|
+
if (b.field === resultRowField) {
|
|
17392
17397
|
return 1;
|
|
17393
17398
|
}
|
|
17394
17399
|
return 0;
|
|
17395
17400
|
});
|
|
17396
|
-
if (
|
|
17401
|
+
if (resultRowField && !isStringType(pivot.rowFieldType || "")) {
|
|
17397
17402
|
rows.forEach((row) => {
|
|
17398
|
-
row.__quillRawDate = typeof row[
|
|
17399
|
-
let value = typeof row[
|
|
17403
|
+
row.__quillRawDate = typeof row[resultRowField] === "object" ? row[resultRowField].value : row[resultRowField];
|
|
17404
|
+
let value = typeof row[resultRowField] === "object" ? row[resultRowField].value : row[resultRowField];
|
|
17400
17405
|
if (dateBucket === "week" && dateFilter?.startDate && dateFilter?.endDate) {
|
|
17401
17406
|
const rowDate = new Date(value);
|
|
17402
17407
|
if (rowDate < dateFilter.startDate) {
|
|
@@ -17411,12 +17416,10 @@ async function generatePivotWithSQL({
|
|
|
17411
17416
|
dateBucket,
|
|
17412
17417
|
databaseType
|
|
17413
17418
|
);
|
|
17414
|
-
row[
|
|
17419
|
+
row[resultRowField] = dateString;
|
|
17415
17420
|
});
|
|
17416
|
-
if (
|
|
17417
|
-
const dateSet = new Set(
|
|
17418
|
-
rows.map((row) => row[pivot.rowField || ""])
|
|
17419
|
-
);
|
|
17421
|
+
if (resultRowField && pivot.rowFieldType && !isStringType(pivot.rowFieldType) && dateFilter?.startDate && dateFilter?.endDate) {
|
|
17422
|
+
const dateSet = new Set(rows.map((row) => row[resultRowField]));
|
|
17420
17423
|
for (let date = dateFilter.startDate; date <= dateFilter.endDate; date = new Date(date.getTime() + 24 * 60 * 60 * 1e3)) {
|
|
17421
17424
|
const formattedDate = getDateString(
|
|
17422
17425
|
date.toISOString(),
|
|
@@ -17426,7 +17429,7 @@ async function generatePivotWithSQL({
|
|
|
17426
17429
|
);
|
|
17427
17430
|
if (!dateSet.has(formattedDate)) {
|
|
17428
17431
|
const newRow = {};
|
|
17429
|
-
newRow[
|
|
17432
|
+
newRow[resultRowField] = formattedDate;
|
|
17430
17433
|
newRow.__quillRawDate = date.toISOString();
|
|
17431
17434
|
rows.push(newRow);
|
|
17432
17435
|
dateSet.add(formattedDate);
|
|
@@ -17463,6 +17466,7 @@ async function generatePivotWithSQL({
|
|
|
17463
17466
|
rows,
|
|
17464
17467
|
columns: columns ?? [],
|
|
17465
17468
|
rowCount: rowCount || rows.length,
|
|
17469
|
+
rowField: resultRowField || void 0,
|
|
17466
17470
|
pivotQuery: report?.queryString || "",
|
|
17467
17471
|
comparisonPivotQuery: comparisonPivotQuery || ""
|
|
17468
17472
|
};
|
|
@@ -17562,14 +17566,18 @@ function processPivotData({
|
|
|
17562
17566
|
rows: responseRows,
|
|
17563
17567
|
fields: responseFields,
|
|
17564
17568
|
pivot,
|
|
17569
|
+
resultRowField,
|
|
17565
17570
|
dateBucket,
|
|
17566
17571
|
dateFilter,
|
|
17567
17572
|
client,
|
|
17568
17573
|
rowCount
|
|
17569
17574
|
}) {
|
|
17570
17575
|
const databaseType = client.databaseType || "postgresql";
|
|
17571
|
-
const
|
|
17572
|
-
(
|
|
17576
|
+
const pivotRowField = processColumnName(
|
|
17577
|
+
String(resultRowField ?? pivot.rowField ?? "")
|
|
17578
|
+
);
|
|
17579
|
+
const rows = pivotRowField ? responseRows.map(
|
|
17580
|
+
(row) => !row[pivotRowField] ? { ...row, [pivotRowField]: "-" } : row
|
|
17573
17581
|
) : responseRows;
|
|
17574
17582
|
if (pivot.columnField && client.databaseType?.toLowerCase() === "bigquery") {
|
|
17575
17583
|
rows.forEach((row) => {
|
|
@@ -17589,27 +17597,27 @@ function processPivotData({
|
|
|
17589
17597
|
(field.field || field.name).replace("comparison_", "comparison ")
|
|
17590
17598
|
)
|
|
17591
17599
|
),
|
|
17592
|
-
format: (field.field || field.name) ===
|
|
17600
|
+
format: processColumnName(field.field || field.name) === pivotRowField ? "string" : pivot.aggregations?.find(
|
|
17593
17601
|
(agg) => agg.valueField === (field.field || field.name) || `${agg.valueField}_percentage` === (field.field || field.name) || !agg.valueField && agg.aggregationType === "percentage" && (field.field || field.name)?.endsWith("percentage")
|
|
17594
17602
|
)?.aggregationType === "percentage" ? "percent" : "whole_number",
|
|
17595
17603
|
fieldType: field.fieldType,
|
|
17596
17604
|
jsType: field.jsType,
|
|
17597
17605
|
dataTypeID: field.dataTypeID
|
|
17598
17606
|
})).filter(
|
|
17599
|
-
(field, index) => field.field !== "comparison_" +
|
|
17607
|
+
(field, index) => field.field !== "comparison_" + pivotRowField || index === 0
|
|
17600
17608
|
).sort((a, b) => {
|
|
17601
|
-
if (a.field ===
|
|
17609
|
+
if (a.field === pivotRowField) {
|
|
17602
17610
|
return -1;
|
|
17603
17611
|
}
|
|
17604
|
-
if (b.field ===
|
|
17612
|
+
if (b.field === pivotRowField) {
|
|
17605
17613
|
return 1;
|
|
17606
17614
|
}
|
|
17607
17615
|
return 0;
|
|
17608
17616
|
});
|
|
17609
|
-
if (
|
|
17617
|
+
if (pivotRowField && !isStringType(pivot.rowFieldType || "")) {
|
|
17610
17618
|
rows.forEach((row) => {
|
|
17611
|
-
row.__quillRawDate = typeof row[
|
|
17612
|
-
let value = typeof row[
|
|
17619
|
+
row.__quillRawDate = typeof row[pivotRowField] === "object" ? row[pivotRowField].value : row[pivotRowField];
|
|
17620
|
+
let value = typeof row[pivotRowField] === "object" ? row[pivotRowField].value : row[pivotRowField];
|
|
17613
17621
|
if (dateBucket === "week" && dateFilter?.startDate && dateFilter?.endDate) {
|
|
17614
17622
|
const rowDate = new Date(value);
|
|
17615
17623
|
if (rowDate < dateFilter.startDate) {
|
|
@@ -17624,12 +17632,10 @@ function processPivotData({
|
|
|
17624
17632
|
dateBucket,
|
|
17625
17633
|
databaseType
|
|
17626
17634
|
);
|
|
17627
|
-
row[
|
|
17635
|
+
row[pivotRowField] = dateString;
|
|
17628
17636
|
});
|
|
17629
|
-
if (
|
|
17630
|
-
const dateSet = new Set(
|
|
17631
|
-
rows.map((row) => row[pivot.rowField || ""])
|
|
17632
|
-
);
|
|
17637
|
+
if (pivotRowField && pivot.rowFieldType && !isStringType(pivot.rowFieldType) && dateFilter?.startDate && dateFilter?.endDate) {
|
|
17638
|
+
const dateSet = new Set(rows.map((row) => row[pivotRowField]));
|
|
17633
17639
|
for (let date = dateFilter.startDate; date <= dateFilter.endDate; date = new Date(date.getTime() + 24 * 60 * 60 * 1e3)) {
|
|
17634
17640
|
const formattedDate = getDateString(
|
|
17635
17641
|
date.toISOString(),
|
|
@@ -17639,7 +17645,7 @@ function processPivotData({
|
|
|
17639
17645
|
);
|
|
17640
17646
|
if (!dateSet.has(formattedDate)) {
|
|
17641
17647
|
const newRow = {};
|
|
17642
|
-
newRow[
|
|
17648
|
+
newRow[pivotRowField] = formattedDate;
|
|
17643
17649
|
newRow.__quillRawDate = date.toISOString();
|
|
17644
17650
|
rows.push(newRow);
|
|
17645
17651
|
dateSet.add(formattedDate);
|
|
@@ -17676,6 +17682,7 @@ function processPivotData({
|
|
|
17676
17682
|
rows,
|
|
17677
17683
|
columns: columns ?? [],
|
|
17678
17684
|
rowCount: rowCount || rows.length,
|
|
17685
|
+
rowField: pivotRowField || void 0,
|
|
17679
17686
|
pivotQuery: "",
|
|
17680
17687
|
comparisonPivotQuery: ""
|
|
17681
17688
|
};
|
|
@@ -21986,12 +21993,14 @@ function buildPivotOnlyReportFromResponse({
|
|
|
21986
21993
|
}
|
|
21987
21994
|
let pivotRows = rawPivotRows;
|
|
21988
21995
|
let pivotColumns = Array.isArray(response?.pivotColumns) ? response.pivotColumns : fallbackBaseReport.pivotColumns ?? [];
|
|
21996
|
+
let pivotResultRowField;
|
|
21989
21997
|
let pivotRowCount = typeof response?.pivotRowCount === "number" ? response.pivotRowCount : typeof response?.rowCount === "number" ? response.rowCount : rawPivotRows.length;
|
|
21990
21998
|
if (effectivePivot && rawPivotFields.length > 0) {
|
|
21991
21999
|
const pivotData = processPivotData({
|
|
21992
22000
|
rows: rawPivotRows,
|
|
21993
22001
|
fields: rawPivotFields,
|
|
21994
22002
|
pivot: effectivePivot,
|
|
22003
|
+
resultRowField: response?.config?.rowField,
|
|
21995
22004
|
...effectivePivot.dateBucket ? { dateBucket: effectivePivot.dateBucket } : {},
|
|
21996
22005
|
client,
|
|
21997
22006
|
rowCount: typeof response?.rowCount === "number" ? response.rowCount : void 0
|
|
@@ -21999,6 +22008,7 @@ function buildPivotOnlyReportFromResponse({
|
|
|
21999
22008
|
pivotRows = pivotData.rows;
|
|
22000
22009
|
pivotColumns = pivotData.columns;
|
|
22001
22010
|
pivotRowCount = pivotData.rowCount;
|
|
22011
|
+
pivotResultRowField = pivotData.rowField;
|
|
22002
22012
|
}
|
|
22003
22013
|
const pivotOnlyReport = {
|
|
22004
22014
|
...responseReport,
|
|
@@ -22010,7 +22020,9 @@ function buildPivotOnlyReportFromResponse({
|
|
|
22010
22020
|
pivot: effectivePivot,
|
|
22011
22021
|
pivotRows,
|
|
22012
22022
|
pivotColumns,
|
|
22013
|
-
pivotRowCount
|
|
22023
|
+
pivotRowCount,
|
|
22024
|
+
pivotResultRowField,
|
|
22025
|
+
pivotResultSourceRowField: effectivePivot?.rowField
|
|
22014
22026
|
};
|
|
22015
22027
|
if (additionalProcessing) {
|
|
22016
22028
|
pivotOnlyReport.pagination = additionalProcessing.page;
|
|
@@ -63372,6 +63384,8 @@ async function loadViaReportBuilderState({
|
|
|
63372
63384
|
pivotRows: refreshedPivotData?.rows ?? compatibleReportPivotRows ?? (canReuseBasePivotRowsAndColumns ? baseReport.pivotRows : []) ?? [],
|
|
63373
63385
|
pivotColumns: refreshedPivotData?.columns ?? compatibleReportPivotColumns ?? (canReuseBasePivotRowsAndColumns ? baseReport.pivotColumns : []) ?? [],
|
|
63374
63386
|
pivotRowCount: refreshedPivotData?.rowCount ?? compatibleReportPivotRowCount ?? (canReuseBasePivotRowsAndColumns ? baseReport.pivotRowCount : void 0) ?? 0,
|
|
63387
|
+
pivotResultRowField: refreshedPivotData?.rowField ?? reportBuilderInfo.report.pivotResultRowField ?? (canReuseBasePivotRowsAndColumns ? baseReport.pivotResultRowField : void 0),
|
|
63388
|
+
pivotResultSourceRowField: refreshedPivotData?.rowField && requestedPivotRowField ? requestedPivotRowField : reportBuilderInfo.report.pivotResultSourceRowField ? reportBuilderInfo.report.pivotResultSourceRowField : canReuseBasePivotRowsAndColumns ? baseReport.pivotResultSourceRowField : void 0,
|
|
63375
63389
|
uniqueStringsByTable: reportBuilderInfo.uniqueStringsByTable,
|
|
63376
63390
|
uniqueStringsByColumn: reportBuilderInfo.uniqueStringsByColumn,
|
|
63377
63391
|
columnUniqueValues: reportBuilderInfo.uniqueStringsByColumn,
|
|
@@ -66411,6 +66425,8 @@ function useReport(reportIdArg, options = {}) {
|
|
|
66411
66425
|
pivotRows: mergedPivotRows,
|
|
66412
66426
|
pivotColumns: report.pivotColumns,
|
|
66413
66427
|
pivotRowCount: mergedPivotRowCount,
|
|
66428
|
+
pivotResultRowField: report.pivotResultRowField,
|
|
66429
|
+
pivotResultSourceRowField: report.pivotResultSourceRowField,
|
|
66414
66430
|
pivotQuery: report.pivotQuery,
|
|
66415
66431
|
comparisonPivotQuery: report.comparisonPivotQuery,
|
|
66416
66432
|
reportBuilderState: mergedReportBuilderState ? {
|
|
@@ -66430,7 +66446,11 @@ function useReport(reportIdArg, options = {}) {
|
|
|
66430
66446
|
const chartData = useMemo33(() => {
|
|
66431
66447
|
if (!sourceReport) return void 0;
|
|
66432
66448
|
const rowsForChart = Array.isArray(sourceReport.rows) ? sourceReport.rows : [];
|
|
66433
|
-
const
|
|
66449
|
+
const chartPivot = nextPivot ?? (!chartPivotHydratedFromSourceRef.current ? sourceReport.pivot ?? null : null);
|
|
66450
|
+
const chartPivotForDisplay = chartPivot && sourceReport.pivotResultRowField && sourceReport.pivotResultSourceRowField === chartPivot.rowField ? {
|
|
66451
|
+
...chartPivot,
|
|
66452
|
+
rowField: sourceReport.pivotResultRowField
|
|
66453
|
+
} : chartPivot;
|
|
66434
66454
|
const rowCountForChart = chartPivotForDisplay ? sourceReport.pivotRowCount ?? (Array.isArray(sourceReport.pivotRows) ? sourceReport.pivotRows.length : sourceReport.rowCount) : useInMemoryEngines ? rowsForChart.length : sourceReport.rowCount;
|
|
66435
66455
|
const referencedTablesForChart = effectiveReportBuilderState?.tables.map((table2) => table2.name).filter((name2) => Boolean(name2));
|
|
66436
66456
|
const pivotRowsForChart = Array.isArray(sourceReport.pivotRows) ? sourceReport.pivotRows : void 0;
|