@quillsql/react 2.12.52 → 2.12.53
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.js +1 -1
- package/dist/cjs/ChartBuilder.d.ts +7 -3
- package/dist/cjs/ChartBuilder.d.ts.map +1 -1
- package/dist/cjs/ChartBuilder.js +54 -18
- package/dist/cjs/ChartEditor.d.ts +3 -1
- package/dist/cjs/ChartEditor.d.ts.map +1 -1
- package/dist/cjs/ChartEditor.js +42 -7
- package/dist/cjs/Context.d.ts +4 -5
- package/dist/cjs/Context.d.ts.map +1 -1
- package/dist/cjs/Context.js +22 -34
- package/dist/cjs/Dashboard.d.ts +4 -3
- package/dist/cjs/Dashboard.d.ts.map +1 -1
- package/dist/cjs/Dashboard.js +24 -29
- package/dist/cjs/DateRangePicker/QuillDateRangePicker.d.ts.map +1 -1
- package/dist/cjs/DateRangePicker/QuillDateRangePicker.js +8 -10
- package/dist/cjs/DateRangePicker/dateRangePickerUtils.d.ts +1 -0
- package/dist/cjs/DateRangePicker/dateRangePickerUtils.d.ts.map +1 -1
- package/dist/cjs/DateRangePicker/dateRangePickerUtils.js +1 -1
- package/dist/cjs/QuillProvider.js +1 -1
- package/dist/cjs/ReportBuilder.d.ts +8 -12
- package/dist/cjs/ReportBuilder.d.ts.map +1 -1
- package/dist/cjs/ReportBuilder.js +157 -83
- package/dist/cjs/SQLEditor.d.ts +8 -1
- package/dist/cjs/SQLEditor.d.ts.map +1 -1
- package/dist/cjs/SQLEditor.js +80 -28
- package/dist/cjs/Table.js +1 -1
- package/dist/cjs/assets/AdjustmentsIcon.d.ts +5 -0
- package/dist/cjs/assets/AdjustmentsIcon.d.ts.map +1 -0
- package/dist/cjs/assets/AdjustmentsIcon.js +5 -0
- package/dist/cjs/assets/ArrowDownHeadIcon.d.ts.map +1 -1
- package/dist/cjs/components/Chart/ChartError.js +2 -2
- package/dist/cjs/components/Dashboard/DashboardFilter.d.ts +2 -2
- 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/DashboardTemplate.d.ts +2 -2
- package/dist/cjs/components/Dashboard/DashboardTemplate.d.ts.map +1 -1
- package/dist/cjs/components/Dashboard/DataLoader.d.ts +5 -1
- package/dist/cjs/components/Dashboard/DataLoader.d.ts.map +1 -1
- package/dist/cjs/components/Dashboard/DataLoader.js +23 -4
- package/dist/cjs/components/Dashboard/TableComponent.d.ts +2 -1
- package/dist/cjs/components/Dashboard/TableComponent.d.ts.map +1 -1
- package/dist/cjs/components/Dashboard/TableComponent.js +2 -2
- package/dist/cjs/components/Dashboard/util.d.ts +2 -2
- package/dist/cjs/components/Dashboard/util.d.ts.map +1 -1
- package/dist/cjs/components/Dashboard/util.js +2 -2
- package/dist/cjs/components/QuillMultiSelect.d.ts.map +1 -1
- package/dist/cjs/components/QuillMultiSelect.js +18 -13
- package/dist/cjs/components/QuillMultiSelectWithCombo.d.ts.map +1 -1
- package/dist/cjs/components/QuillMultiSelectWithCombo.js +67 -45
- package/dist/cjs/components/QuillSelect.d.ts +1 -1
- package/dist/cjs/components/QuillSelect.d.ts.map +1 -1
- package/dist/cjs/components/QuillSelect.js +28 -6
- package/dist/cjs/components/QuillSelectWithCombo.d.ts.map +1 -1
- package/dist/cjs/components/QuillSelectWithCombo.js +45 -24
- package/dist/cjs/components/QuillTable.d.ts +2 -1
- package/dist/cjs/components/QuillTable.d.ts.map +1 -1
- package/dist/cjs/components/QuillTable.js +7 -4
- package/dist/cjs/components/ReportBuilder/AddLimitPopover.d.ts +2 -1
- package/dist/cjs/components/ReportBuilder/AddLimitPopover.d.ts.map +1 -1
- package/dist/cjs/components/ReportBuilder/AddLimitPopover.js +2 -2
- package/dist/cjs/components/ReportBuilder/AddSortPopover.d.ts +2 -1
- package/dist/cjs/components/ReportBuilder/AddSortPopover.d.ts.map +1 -1
- package/dist/cjs/components/ReportBuilder/AddSortPopover.js +2 -2
- package/dist/cjs/components/ReportBuilder/FilterModal.d.ts +2 -1
- package/dist/cjs/components/ReportBuilder/FilterModal.d.ts.map +1 -1
- package/dist/cjs/components/ReportBuilder/FilterModal.js +17 -4
- package/dist/cjs/components/ReportBuilder/ui.d.ts +13 -7
- package/dist/cjs/components/ReportBuilder/ui.d.ts.map +1 -1
- package/dist/cjs/components/ReportBuilder/ui.js +14 -11
- package/dist/cjs/components/UiComponents.d.ts +15 -8
- package/dist/cjs/components/UiComponents.d.ts.map +1 -1
- package/dist/cjs/components/UiComponents.js +29 -23
- package/dist/cjs/hooks/useAstToFilterTree.d.ts +2 -2
- package/dist/cjs/hooks/useAstToFilterTree.d.ts.map +1 -1
- package/dist/cjs/hooks/useDashboard.d.ts +9 -4
- package/dist/cjs/hooks/useDashboard.d.ts.map +1 -1
- package/dist/cjs/hooks/useDashboard.js +61 -38
- package/dist/cjs/hooks/useExport.js +1 -1
- package/dist/cjs/hooks/useQuill.js +2 -2
- package/dist/cjs/hooks/useVirtualTables.d.ts +12 -3
- package/dist/cjs/hooks/useVirtualTables.d.ts.map +1 -1
- package/dist/cjs/hooks/useVirtualTables.js +105 -1
- package/dist/cjs/internals/ReportBuilder/PivotForm.d.ts +3 -1
- package/dist/cjs/internals/ReportBuilder/PivotForm.d.ts.map +1 -1
- package/dist/cjs/internals/ReportBuilder/PivotForm.js +9 -9
- package/dist/cjs/internals/ReportBuilder/PivotList.d.ts.map +1 -1
- package/dist/cjs/internals/ReportBuilder/PivotList.js +21 -15
- package/dist/cjs/internals/ReportBuilder/PivotModal.d.ts +3 -2
- package/dist/cjs/internals/ReportBuilder/PivotModal.d.ts.map +1 -1
- package/dist/cjs/internals/ReportBuilder/PivotModal.js +9 -9
- package/dist/cjs/models/Client.d.ts +10 -2
- package/dist/cjs/models/Client.d.ts.map +1 -1
- package/dist/cjs/utils/astProcessing.d.ts +3 -3
- package/dist/cjs/utils/astProcessing.d.ts.map +1 -1
- package/dist/cjs/utils/client.d.ts.map +1 -1
- package/dist/cjs/utils/client.js +2 -7
- package/dist/cjs/utils/dashboard.d.ts +5 -5
- package/dist/cjs/utils/dashboard.d.ts.map +1 -1
- package/dist/cjs/utils/dashboard.js +87 -7
- package/dist/cjs/utils/dataFetcher.d.ts +4 -4
- package/dist/cjs/utils/dataFetcher.d.ts.map +1 -1
- package/dist/cjs/utils/dataFetcher.js +1 -1
- package/dist/cjs/utils/filterProcessing.d.ts.map +1 -1
- package/dist/cjs/utils/filterProcessing.js +2 -8
- package/dist/cjs/utils/paginationProcessing.js +1 -1
- package/dist/cjs/utils/pivotConstructor.d.ts +2 -2
- package/dist/cjs/utils/pivotConstructor.d.ts.map +1 -1
- package/dist/cjs/utils/pivotConstructor.js +1 -1
- package/dist/cjs/utils/pivotProcessing.d.ts.map +1 -1
- package/dist/cjs/utils/pivotProcessing.js +6 -2
- package/dist/cjs/utils/queryConstructor.d.ts.map +1 -1
- package/dist/cjs/utils/queryConstructor.js +12 -9
- package/dist/cjs/utils/report.d.ts +6 -5
- package/dist/cjs/utils/report.d.ts.map +1 -1
- package/dist/cjs/utils/report.js +69 -24
- package/dist/cjs/utils/schema.d.ts +3 -3
- package/dist/cjs/utils/schema.d.ts.map +1 -1
- package/dist/cjs/utils/schema.js +39 -35
- package/dist/cjs/utils/tableProcessing.d.ts +17 -10
- package/dist/cjs/utils/tableProcessing.d.ts.map +1 -1
- package/dist/cjs/utils/tableProcessing.js +42 -23
- package/dist/esm/Chart.js +2 -2
- package/dist/esm/ChartBuilder.d.ts +7 -3
- package/dist/esm/ChartBuilder.d.ts.map +1 -1
- package/dist/esm/ChartBuilder.js +51 -18
- package/dist/esm/ChartEditor.d.ts +3 -1
- package/dist/esm/ChartEditor.d.ts.map +1 -1
- package/dist/esm/ChartEditor.js +43 -8
- package/dist/esm/Context.d.ts +4 -5
- package/dist/esm/Context.d.ts.map +1 -1
- package/dist/esm/Context.js +23 -35
- package/dist/esm/Dashboard.d.ts +4 -3
- package/dist/esm/Dashboard.d.ts.map +1 -1
- package/dist/esm/Dashboard.js +24 -29
- package/dist/esm/DateRangePicker/QuillDateRangePicker.d.ts.map +1 -1
- package/dist/esm/DateRangePicker/QuillDateRangePicker.js +8 -10
- package/dist/esm/DateRangePicker/dateRangePickerUtils.d.ts +1 -0
- package/dist/esm/DateRangePicker/dateRangePickerUtils.d.ts.map +1 -1
- package/dist/esm/DateRangePicker/dateRangePickerUtils.js +1 -1
- package/dist/esm/QuillProvider.js +1 -1
- package/dist/esm/ReportBuilder.d.ts +8 -12
- package/dist/esm/ReportBuilder.d.ts.map +1 -1
- package/dist/esm/ReportBuilder.js +160 -86
- package/dist/esm/SQLEditor.d.ts +8 -1
- package/dist/esm/SQLEditor.d.ts.map +1 -1
- package/dist/esm/SQLEditor.js +83 -31
- package/dist/esm/Table.js +2 -2
- package/dist/esm/assets/AdjustmentsIcon.d.ts +5 -0
- package/dist/esm/assets/AdjustmentsIcon.d.ts.map +1 -0
- package/dist/esm/assets/AdjustmentsIcon.js +3 -0
- package/dist/esm/assets/ArrowDownHeadIcon.d.ts.map +1 -1
- package/dist/esm/components/Chart/ChartError.js +2 -2
- package/dist/esm/components/Dashboard/DashboardFilter.d.ts +2 -2
- package/dist/esm/components/Dashboard/DashboardFilter.d.ts.map +1 -1
- package/dist/esm/components/Dashboard/DashboardFilter.js +6 -6
- package/dist/esm/components/Dashboard/DashboardTemplate.d.ts +2 -2
- package/dist/esm/components/Dashboard/DashboardTemplate.d.ts.map +1 -1
- package/dist/esm/components/Dashboard/DataLoader.d.ts +5 -1
- package/dist/esm/components/Dashboard/DataLoader.d.ts.map +1 -1
- package/dist/esm/components/Dashboard/DataLoader.js +25 -6
- package/dist/esm/components/Dashboard/TableComponent.d.ts +2 -1
- package/dist/esm/components/Dashboard/TableComponent.d.ts.map +1 -1
- package/dist/esm/components/Dashboard/TableComponent.js +2 -2
- package/dist/esm/components/Dashboard/util.d.ts +2 -2
- package/dist/esm/components/Dashboard/util.d.ts.map +1 -1
- package/dist/esm/components/Dashboard/util.js +2 -2
- package/dist/esm/components/QuillMultiSelect.d.ts.map +1 -1
- package/dist/esm/components/QuillMultiSelect.js +19 -14
- package/dist/esm/components/QuillMultiSelectWithCombo.d.ts.map +1 -1
- package/dist/esm/components/QuillMultiSelectWithCombo.js +68 -46
- package/dist/esm/components/QuillSelect.d.ts +1 -1
- package/dist/esm/components/QuillSelect.d.ts.map +1 -1
- package/dist/esm/components/QuillSelect.js +29 -7
- package/dist/esm/components/QuillSelectWithCombo.d.ts.map +1 -1
- package/dist/esm/components/QuillSelectWithCombo.js +46 -25
- package/dist/esm/components/QuillTable.d.ts +2 -1
- package/dist/esm/components/QuillTable.d.ts.map +1 -1
- package/dist/esm/components/QuillTable.js +7 -4
- package/dist/esm/components/ReportBuilder/AddLimitPopover.d.ts +2 -1
- package/dist/esm/components/ReportBuilder/AddLimitPopover.d.ts.map +1 -1
- package/dist/esm/components/ReportBuilder/AddLimitPopover.js +2 -2
- package/dist/esm/components/ReportBuilder/AddSortPopover.d.ts +2 -1
- package/dist/esm/components/ReportBuilder/AddSortPopover.d.ts.map +1 -1
- package/dist/esm/components/ReportBuilder/AddSortPopover.js +2 -2
- package/dist/esm/components/ReportBuilder/FilterModal.d.ts +2 -1
- package/dist/esm/components/ReportBuilder/FilterModal.d.ts.map +1 -1
- package/dist/esm/components/ReportBuilder/FilterModal.js +17 -4
- package/dist/esm/components/ReportBuilder/ui.d.ts +13 -7
- package/dist/esm/components/ReportBuilder/ui.d.ts.map +1 -1
- package/dist/esm/components/ReportBuilder/ui.js +14 -11
- package/dist/esm/components/UiComponents.d.ts +15 -8
- package/dist/esm/components/UiComponents.d.ts.map +1 -1
- package/dist/esm/components/UiComponents.js +29 -23
- package/dist/esm/hooks/useAstToFilterTree.d.ts +2 -2
- package/dist/esm/hooks/useAstToFilterTree.d.ts.map +1 -1
- package/dist/esm/hooks/useDashboard.d.ts +9 -4
- package/dist/esm/hooks/useDashboard.d.ts.map +1 -1
- package/dist/esm/hooks/useDashboard.js +62 -39
- package/dist/esm/hooks/useExport.js +1 -1
- package/dist/esm/hooks/useQuill.js +3 -3
- package/dist/esm/hooks/useVirtualTables.d.ts +12 -3
- package/dist/esm/hooks/useVirtualTables.d.ts.map +1 -1
- package/dist/esm/hooks/useVirtualTables.js +106 -2
- package/dist/esm/internals/ReportBuilder/PivotForm.d.ts +3 -1
- package/dist/esm/internals/ReportBuilder/PivotForm.d.ts.map +1 -1
- package/dist/esm/internals/ReportBuilder/PivotForm.js +9 -9
- package/dist/esm/internals/ReportBuilder/PivotList.d.ts.map +1 -1
- package/dist/esm/internals/ReportBuilder/PivotList.js +21 -15
- package/dist/esm/internals/ReportBuilder/PivotModal.d.ts +3 -2
- package/dist/esm/internals/ReportBuilder/PivotModal.d.ts.map +1 -1
- package/dist/esm/internals/ReportBuilder/PivotModal.js +9 -9
- package/dist/esm/models/Client.d.ts +10 -2
- package/dist/esm/models/Client.d.ts.map +1 -1
- package/dist/esm/utils/astProcessing.d.ts +3 -3
- package/dist/esm/utils/astProcessing.d.ts.map +1 -1
- package/dist/esm/utils/client.d.ts.map +1 -1
- package/dist/esm/utils/client.js +2 -7
- package/dist/esm/utils/dashboard.d.ts +5 -5
- package/dist/esm/utils/dashboard.d.ts.map +1 -1
- package/dist/esm/utils/dashboard.js +87 -7
- package/dist/esm/utils/dataFetcher.d.ts +4 -4
- package/dist/esm/utils/dataFetcher.d.ts.map +1 -1
- package/dist/esm/utils/dataFetcher.js +1 -1
- package/dist/esm/utils/filterProcessing.d.ts.map +1 -1
- package/dist/esm/utils/filterProcessing.js +2 -8
- package/dist/esm/utils/paginationProcessing.js +1 -1
- package/dist/esm/utils/pivotConstructor.d.ts +2 -2
- package/dist/esm/utils/pivotConstructor.d.ts.map +1 -1
- package/dist/esm/utils/pivotConstructor.js +1 -1
- package/dist/esm/utils/pivotProcessing.d.ts.map +1 -1
- package/dist/esm/utils/pivotProcessing.js +6 -2
- package/dist/esm/utils/queryConstructor.d.ts.map +1 -1
- package/dist/esm/utils/queryConstructor.js +12 -9
- package/dist/esm/utils/report.d.ts +6 -5
- package/dist/esm/utils/report.d.ts.map +1 -1
- package/dist/esm/utils/report.js +68 -24
- package/dist/esm/utils/schema.d.ts +3 -3
- package/dist/esm/utils/schema.d.ts.map +1 -1
- package/dist/esm/utils/schema.js +39 -35
- package/dist/esm/utils/tableProcessing.d.ts +17 -10
- package/dist/esm/utils/tableProcessing.d.ts.map +1 -1
- package/dist/esm/utils/tableProcessing.js +39 -20
- package/package.json +1 -1
package/dist/esm/utils/report.js
CHANGED
|
@@ -13,7 +13,7 @@ import { internalLog } from './logging';
|
|
|
13
13
|
import { mergeComparisonRange } from './merge';
|
|
14
14
|
import { DEFAULT_PAGINATION } from './paginationProcessing';
|
|
15
15
|
import { isPivotPossible, isValidPivot } from './pivotProcessing';
|
|
16
|
-
import { fetchTableByAST, getRelevantInfoFromQuery, } from './tableProcessing';
|
|
16
|
+
import { fetchTableByAST, getDateRangeByColumns, getRelevantInfoFromQuery, } from './tableProcessing';
|
|
17
17
|
import { snakeAndCamelCaseToTitleCase } from './textProcessing';
|
|
18
18
|
import { quillFormat } from './valueFormatter';
|
|
19
19
|
export const EMPTY_REPORT = {
|
|
@@ -61,7 +61,7 @@ function extractAllReportValuesFromQuillInternalReport(reportInternal) {
|
|
|
61
61
|
template: reportInternal.template,
|
|
62
62
|
};
|
|
63
63
|
}
|
|
64
|
-
export async function fetchReport(reportId, client, useReportTask = true, filters = [], additionalProcessing, dateBucket, customFields) {
|
|
64
|
+
export async function fetchReport(reportId, client, useReportTask = true, filters = [], additionalProcessing, dateBucket, customFields, queryTask) {
|
|
65
65
|
let reportInfo = undefined;
|
|
66
66
|
let errorMessage = undefined;
|
|
67
67
|
try {
|
|
@@ -70,7 +70,7 @@ export async function fetchReport(reportId, client, useReportTask = true, filter
|
|
|
70
70
|
metadata: {
|
|
71
71
|
reportId,
|
|
72
72
|
dashboardItemId: reportId,
|
|
73
|
-
orgId: client.
|
|
73
|
+
orgId: client.organizationId || '*',
|
|
74
74
|
clientId: client.publicKey,
|
|
75
75
|
task: useReportTask ? 'report' : 'item',
|
|
76
76
|
databaseType: client.databaseType,
|
|
@@ -78,6 +78,7 @@ export async function fetchReport(reportId, client, useReportTask = true, filter
|
|
|
78
78
|
customFields,
|
|
79
79
|
additionalProcessing,
|
|
80
80
|
useNewNodeSql: true,
|
|
81
|
+
queryTask,
|
|
81
82
|
},
|
|
82
83
|
};
|
|
83
84
|
const cloudBody = {
|
|
@@ -113,8 +114,11 @@ export async function fetchReport(reportId, client, useReportTask = true, filter
|
|
|
113
114
|
// Ensure the report columns don't reference any columns that aren't present in the rows
|
|
114
115
|
const observedColumns = reportInfo?.rows[0]
|
|
115
116
|
? Object.keys(reportInfo.rows[0])
|
|
116
|
-
:
|
|
117
|
-
if (
|
|
117
|
+
: null;
|
|
118
|
+
if (observedColumns &&
|
|
119
|
+
reportInfo &&
|
|
120
|
+
!reportInfo.pivot &&
|
|
121
|
+
!reportInfo.pivotColumns &&
|
|
118
122
|
useReportTask &&
|
|
119
123
|
reportInfo.columns?.filter((col) => !observedColumns.includes(col.field))
|
|
120
124
|
?.length > 0) {
|
|
@@ -131,7 +135,7 @@ export async function fetchReport(reportId, client, useReportTask = true, filter
|
|
|
131
135
|
if (error instanceof DataLoadError) {
|
|
132
136
|
if (error.data.useReportTask) {
|
|
133
137
|
internalLog('USING ITEM AS BACKUP');
|
|
134
|
-
const { report, error } = await fetchReport(reportId, client, false, filters, additionalProcessing, dateBucket, customFields);
|
|
138
|
+
const { report, error } = await fetchReport(reportId, client, false, filters, additionalProcessing, dateBucket, customFields, queryTask);
|
|
135
139
|
reportInfo = report;
|
|
136
140
|
errorMessage = error;
|
|
137
141
|
}
|
|
@@ -158,12 +162,37 @@ export async function fetchReport(reportId, client, useReportTask = true, filter
|
|
|
158
162
|
}
|
|
159
163
|
return { report: reportInfo || EMPTY_INTERNAL_REPORT, error: errorMessage };
|
|
160
164
|
}
|
|
165
|
+
export async function fetchReportRowCount(reportId, client, useReportTask = true, filters = [], additionalProcessing, customFields) {
|
|
166
|
+
// Remove extra fields on each filter so we don't confuse the backend.
|
|
167
|
+
const hostedBody = {
|
|
168
|
+
metadata: {
|
|
169
|
+
reportId,
|
|
170
|
+
dashboardItemId: reportId,
|
|
171
|
+
orgId: client.organizationId || '*',
|
|
172
|
+
clientId: client.publicKey,
|
|
173
|
+
task: useReportTask ? 'report' : 'item',
|
|
174
|
+
databaseType: client.databaseType,
|
|
175
|
+
filters: filters,
|
|
176
|
+
customFields,
|
|
177
|
+
additionalProcessing,
|
|
178
|
+
useNewNodeSql: true,
|
|
179
|
+
rowCountOnly: true,
|
|
180
|
+
},
|
|
181
|
+
};
|
|
182
|
+
const cloudBody = {
|
|
183
|
+
id: reportId,
|
|
184
|
+
filters: filters,
|
|
185
|
+
useNewNodeSql: true,
|
|
186
|
+
};
|
|
187
|
+
const resp = await getData(client, 'itempost', 'omit', hostedBody, cloudBody, 'POST', 'fetch-data');
|
|
188
|
+
return resp.rowCount;
|
|
189
|
+
}
|
|
161
190
|
export async function saveReport({ report, dashboardItemId, client, }) {
|
|
162
|
-
const { publicKey,
|
|
191
|
+
const { publicKey, organizationId, databaseType } = client;
|
|
163
192
|
const cloudBody = {
|
|
164
193
|
...report,
|
|
165
194
|
dashboardItemId,
|
|
166
|
-
customerId:
|
|
195
|
+
customerId: organizationId || '*',
|
|
167
196
|
useNewNodeSql: true,
|
|
168
197
|
};
|
|
169
198
|
// @ts-ignore
|
|
@@ -181,14 +210,14 @@ export async function saveReport({ report, dashboardItemId, client, }) {
|
|
|
181
210
|
clientId: publicKey,
|
|
182
211
|
databaseType: databaseType,
|
|
183
212
|
...cloudBody,
|
|
184
|
-
orgId:
|
|
213
|
+
orgId: organizationId || '*',
|
|
185
214
|
useNewNodeSql: true,
|
|
186
215
|
},
|
|
187
216
|
};
|
|
188
|
-
const searchParams = new URLSearchParams(
|
|
217
|
+
const searchParams = new URLSearchParams(organizationId
|
|
189
218
|
? {
|
|
190
219
|
clientId: publicKey,
|
|
191
|
-
customerId:
|
|
220
|
+
customerId: organizationId,
|
|
192
221
|
}
|
|
193
222
|
: { clientId: publicKey }).toString();
|
|
194
223
|
return await getData(client, `dashedit2?${searchParams}`, 'same-origin', hostedBody, cloudBody);
|
|
@@ -265,7 +294,7 @@ export function convertInternalReportToReport(report) {
|
|
|
265
294
|
return EMPTY_REPORT;
|
|
266
295
|
}
|
|
267
296
|
}
|
|
268
|
-
export const fetchReportBuilderDataFromAST = async (baseAst, formData, schema, client, pivot, previousFormData, currentTable, previousRelevant, report, customFields) => {
|
|
297
|
+
export const fetchReportBuilderDataFromAST = async (baseAst, formData, schema, client, pivot, previousFormData, currentTable, previousRelevant, report, customFields, skipUniqueValues, skipRowCount, processing) => {
|
|
269
298
|
let newRows = [];
|
|
270
299
|
let newColumns = [];
|
|
271
300
|
let newRowCount = 0;
|
|
@@ -276,7 +305,7 @@ export const fetchReportBuilderDataFromAST = async (baseAst, formData, schema, c
|
|
|
276
305
|
let table = '';
|
|
277
306
|
let error;
|
|
278
307
|
const relevantInfo = previousRelevant ?? { uniqueStrings: {}, dateRanges: {} };
|
|
279
|
-
|
|
308
|
+
let query = '';
|
|
280
309
|
try {
|
|
281
310
|
const tables = getTableNames(baseAst);
|
|
282
311
|
table = tables[0] ? tables[0] : '';
|
|
@@ -284,7 +313,7 @@ export const fetchReportBuilderDataFromAST = async (baseAst, formData, schema, c
|
|
|
284
313
|
if (!table || !tableInfo) {
|
|
285
314
|
throw new Error('No table found;');
|
|
286
315
|
}
|
|
287
|
-
const tableData = await fetchTableByAST({ ...baseAst, where: formData }, client, { page: DEFAULT_PAGINATION });
|
|
316
|
+
const tableData = await fetchTableByAST({ ...baseAst, where: formData }, client, processing ?? { page: DEFAULT_PAGINATION }, undefined, skipRowCount);
|
|
288
317
|
if (tableData.error) {
|
|
289
318
|
throw new Error(tableData.error);
|
|
290
319
|
}
|
|
@@ -308,17 +337,32 @@ export const fetchReportBuilderDataFromAST = async (baseAst, formData, schema, c
|
|
|
308
337
|
}),
|
|
309
338
|
columnInternal: tableData.columns,
|
|
310
339
|
};
|
|
311
|
-
const queryResult = await fetchSqlQuery({
|
|
312
|
-
...createBasicSelectASTFromColumns(tableInfo.columns, table),
|
|
313
|
-
where: formData,
|
|
314
|
-
}, client, formData);
|
|
315
|
-
if (queryResult.error) {
|
|
316
|
-
throw new Error(queryResult.error);
|
|
317
|
-
}
|
|
318
340
|
if (table !== currentTable || previousFormData !== formData) {
|
|
319
|
-
const
|
|
320
|
-
|
|
321
|
-
|
|
341
|
+
const queryResult = await fetchSqlQuery({
|
|
342
|
+
...createBasicSelectASTFromColumns(tableInfo.columns, table),
|
|
343
|
+
where: formData,
|
|
344
|
+
}, client, formData);
|
|
345
|
+
if (queryResult.error) {
|
|
346
|
+
throw new Error(queryResult.error);
|
|
347
|
+
}
|
|
348
|
+
query = queryResult.query;
|
|
349
|
+
if (!skipUniqueValues) {
|
|
350
|
+
const { uniqueStrings, dateRanges } = await getRelevantInfoFromQuery(tableInfo.columns, client, queryResult.query, customFields);
|
|
351
|
+
relevantInfo.uniqueStrings[table] = uniqueStrings ?? {};
|
|
352
|
+
relevantInfo.dateRanges = dateRanges ?? {};
|
|
353
|
+
}
|
|
354
|
+
else {
|
|
355
|
+
const dateColumns = tableInfo.columns.filter((column) => {
|
|
356
|
+
return column.fieldType === 'date';
|
|
357
|
+
});
|
|
358
|
+
if (dateColumns.length > 0) {
|
|
359
|
+
const dateRanges = await getDateRangeByColumns(dateColumns, queryResult.query, client, customFields ?? []);
|
|
360
|
+
if (dateRanges === null) {
|
|
361
|
+
throw new Error("Couldn't fetch date ranges");
|
|
362
|
+
}
|
|
363
|
+
relevantInfo.dateRanges = dateRanges ?? {};
|
|
364
|
+
}
|
|
365
|
+
}
|
|
322
366
|
}
|
|
323
367
|
if (!!relevantInfo.error) {
|
|
324
368
|
throw new Error(relevantInfo.error);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { QuillProviderClient } from '../models/Client';
|
|
2
2
|
import { Table } from '../models/Tables';
|
|
3
|
-
export declare const getCustomFieldInfo: (client:
|
|
4
|
-
export declare const getSchemaInfoWithCustomFields: (client:
|
|
3
|
+
export declare const getCustomFieldInfo: (client: QuillProviderClient, caller?: string) => Promise<any[]>;
|
|
4
|
+
export declare const getSchemaInfoWithCustomFields: (client: QuillProviderClient, caller?: string, tableIds?: string[]) => Promise<{
|
|
5
5
|
schemaData: Table[];
|
|
6
6
|
customFieldsByTable: any;
|
|
7
7
|
}>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/utils/schema.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/utils/schema.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAyDzC,eAAO,MAAM,kBAAkB,WACrB,mBAAmB,oCAqF5B,CAAC;AAEF,eAAO,MAAM,6BAA6B,WAChC,mBAAmB,8BAEhB,MAAM,EAAE,KAClB,QAAQ;IAAE,UAAU,EAAE,KAAK,EAAE,CAAC;IAAC,mBAAmB,EAAE,GAAG,CAAA;CAAE,CAoD3D,CAAC"}
|
package/dist/esm/utils/schema.js
CHANGED
|
@@ -1,30 +1,33 @@
|
|
|
1
1
|
import { convertColumnInfoToColumnInternal } from './columnProcessing';
|
|
2
|
-
const triggerSoftUpdate = async (
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
};
|
|
2
|
+
// const triggerSoftUpdate = async (
|
|
3
|
+
// client: QuillProviderClient,
|
|
4
|
+
// tables: Table[],
|
|
5
|
+
// ) => {
|
|
6
|
+
// const { queryEndpoint, queryHeaders, publicKey, withCredentials } = client;
|
|
7
|
+
// tables.forEach(async (table: Table) => {
|
|
8
|
+
// // if (table.isSelectStar) {
|
|
9
|
+
// fetch(`${queryEndpoint}?update-view`, {
|
|
10
|
+
// method: 'POST',
|
|
11
|
+
// headers: {
|
|
12
|
+
// ...queryHeaders,
|
|
13
|
+
// 'Content-Type': 'application/json',
|
|
14
|
+
// },
|
|
15
|
+
// credentials: withCredentials ? 'include' : 'omit',
|
|
16
|
+
// body: JSON.stringify({
|
|
17
|
+
// metadata: {
|
|
18
|
+
// preQueries: [table.viewQuery.replace(/;/, '')],
|
|
19
|
+
// clientId: publicKey,
|
|
20
|
+
// publicKey: publicKey,
|
|
21
|
+
// task: 'update-view',
|
|
22
|
+
// name: table.name,
|
|
23
|
+
// id: table._id,
|
|
24
|
+
// runQueryConfig: { getColumns: true },
|
|
25
|
+
// },
|
|
26
|
+
// }),
|
|
27
|
+
// });
|
|
28
|
+
// // }
|
|
29
|
+
// });
|
|
30
|
+
// };
|
|
28
31
|
const parseResponse = (results) => {
|
|
29
32
|
if (results.data?.data) {
|
|
30
33
|
if (results.data.data.queries &&
|
|
@@ -49,7 +52,7 @@ const parseResponse = (results) => {
|
|
|
49
52
|
export const getCustomFieldInfo = async (client, caller = 'se') => {
|
|
50
53
|
let customFieldsByTableUnique = [];
|
|
51
54
|
try {
|
|
52
|
-
const { queryEndpoint, queryHeaders, publicKey, databaseType,
|
|
55
|
+
const { queryEndpoint, queryHeaders, publicKey, databaseType, organizationId, } = client;
|
|
53
56
|
if ((databaseType && databaseType.toLowerCase() !== 'postgresql') ||
|
|
54
57
|
!['665610862cf7a3000be66453'].includes(publicKey)) {
|
|
55
58
|
throw new Error('CUSTOM FIELDS IS ONLY ALLOWED FOR POSTGRESQL DATABASES');
|
|
@@ -67,7 +70,7 @@ export const getCustomFieldInfo = async (client, caller = 'se') => {
|
|
|
67
70
|
publicKey,
|
|
68
71
|
task: 'custom-field-records',
|
|
69
72
|
databaseType: databaseType,
|
|
70
|
-
orgId:
|
|
73
|
+
orgId: organizationId,
|
|
71
74
|
},
|
|
72
75
|
}),
|
|
73
76
|
});
|
|
@@ -111,11 +114,11 @@ export const getCustomFieldInfo = async (client, caller = 'se') => {
|
|
|
111
114
|
}
|
|
112
115
|
return customFieldsByTableUnique;
|
|
113
116
|
};
|
|
114
|
-
export const getSchemaInfoWithCustomFields = async (client, caller = 'se') => {
|
|
115
|
-
const { queryEndpoint, queryHeaders, publicKey,
|
|
117
|
+
export const getSchemaInfoWithCustomFields = async (client, caller = 'se', tableIds) => {
|
|
118
|
+
const { queryEndpoint, queryHeaders, publicKey, organizationId, withCredentials, } = client;
|
|
116
119
|
let customFieldsByTableUnique = [];
|
|
117
120
|
let getCustomFields = true;
|
|
118
|
-
if (!
|
|
121
|
+
if (!organizationId || organizationId !== '*') {
|
|
119
122
|
try {
|
|
120
123
|
customFieldsByTableUnique = await getCustomFieldInfo(client, caller);
|
|
121
124
|
}
|
|
@@ -136,12 +139,13 @@ export const getSchemaInfoWithCustomFields = async (client, caller = 'se') => {
|
|
|
136
139
|
publicKey: publicKey,
|
|
137
140
|
task: 'schema',
|
|
138
141
|
removeCustomerField: true,
|
|
139
|
-
getCustomFields: !client.
|
|
140
|
-
client.
|
|
142
|
+
getCustomFields: !client.organizationId ||
|
|
143
|
+
client.organizationId === '*' ||
|
|
141
144
|
(customFieldsByTableUnique.length === 0 && !getCustomFields)
|
|
142
145
|
? false
|
|
143
146
|
: true,
|
|
144
|
-
orgId: client.
|
|
147
|
+
orgId: client.organizationId || '*',
|
|
148
|
+
tableIds,
|
|
145
149
|
customFieldsByTable: customFieldsByTableUnique,
|
|
146
150
|
gatherSchemaData: '665610862cf7a3000be66453' === publicKey ? true : false,
|
|
147
151
|
},
|
|
@@ -150,7 +154,7 @@ export const getSchemaInfoWithCustomFields = async (client, caller = 'se') => {
|
|
|
150
154
|
const result = await response.json();
|
|
151
155
|
const parsedData = parseResponse(result);
|
|
152
156
|
const converted = convertSchemaInfoToTable(parsedData);
|
|
153
|
-
triggerSoftUpdate(client, converted);
|
|
157
|
+
// triggerSoftUpdate(client, converted);
|
|
154
158
|
return {
|
|
155
159
|
schemaData: converted,
|
|
156
160
|
customFieldsByTable: customFieldsByTableUnique,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { NodeSQLParser } from '../components/ReportBuilder/ast';
|
|
2
|
-
import {
|
|
2
|
+
import { QuillProviderClient } from '../models/Client';
|
|
3
3
|
import { Column, ColumnInternal } from '../models/Columns';
|
|
4
|
+
import { Filter } from '../models/Filter';
|
|
4
5
|
import { Pagination } from '../models/Pagination';
|
|
5
6
|
import { DateRangesByColumn, UniqueValuesByColumn } from '../models/Tables';
|
|
6
7
|
export interface AdditionalProcessing {
|
|
@@ -12,19 +13,22 @@ export interface AdditionalProcessing {
|
|
|
12
13
|
last?: any;
|
|
13
14
|
}
|
|
14
15
|
export declare const hasColumnAlias: (columns: Column[], referencedColumns: string[]) => boolean;
|
|
15
|
-
export declare const getUniqueValuesByColumns: (columns: Column[], query: string, rows: any, client:
|
|
16
|
+
export declare const getUniqueValuesByColumns: (columns: Column[], query: string, rows: any, client: QuillProviderClient, customFields: any[]) => Promise<{
|
|
16
17
|
[column: string]: {
|
|
17
18
|
[value: string]: boolean;
|
|
18
19
|
};
|
|
19
20
|
} | null>;
|
|
20
|
-
export declare const getUniqueStringValues: (columns: ColumnInternal[], tableName: string, client: any, customFields?: any, previousUniqueValues?: any) => Promise<any>;
|
|
21
|
-
export declare const getRelevantInfoFromQuery: (columns: ColumnInternal[], client:
|
|
21
|
+
export declare const getUniqueStringValues: (columns: ColumnInternal[], tableName: string, client: any, customFields?: any, previousUniqueValues?: any, withExceededColumns?: boolean, query?: string) => Promise<any>;
|
|
22
|
+
export declare const getRelevantInfoFromQuery: (columns: ColumnInternal[], client: QuillProviderClient, query: string, customFields?: any) => Promise<{
|
|
22
23
|
uniqueStrings?: UniqueValuesByColumn | undefined;
|
|
23
24
|
dateRanges?: DateRangesByColumn | undefined;
|
|
24
25
|
error?: string | undefined;
|
|
25
26
|
}>;
|
|
26
|
-
export declare const getCountsByColumns: (columns: Column[], query: string, client:
|
|
27
|
-
|
|
27
|
+
export declare const getCountsByColumns: (columns: Column[], query: string, client: QuillProviderClient, customFields: any[]) => Promise<{
|
|
28
|
+
filteredColumns: Column[];
|
|
29
|
+
exceededColumns: Column[] | undefined;
|
|
30
|
+
}>;
|
|
31
|
+
export declare const getDateRangeByColumns: (columns: Column[], query: string, client: QuillProviderClient, customFields: any[]) => Promise<{
|
|
28
32
|
[column: string]: {
|
|
29
33
|
dateRange: {
|
|
30
34
|
start: Date;
|
|
@@ -32,26 +36,29 @@ export declare const getDateRangeByColumns: (columns: Column[], query: string, c
|
|
|
32
36
|
};
|
|
33
37
|
};
|
|
34
38
|
} | null>;
|
|
35
|
-
export declare const getPaginatedRows: (client:
|
|
39
|
+
export declare const getPaginatedRows: (client: QuillProviderClient, query?: string, reportId?: string, processing?: AdditionalProcessing, filters?: any, customFields?: any) => Promise<{
|
|
36
40
|
columns: Column[];
|
|
37
41
|
rows: any[];
|
|
38
42
|
rowCount?: number;
|
|
39
43
|
error?: string;
|
|
40
44
|
}>;
|
|
41
|
-
export declare const
|
|
45
|
+
export declare const fetchResultsByQuery: (query: string, client: QuillProviderClient, processing?: AdditionalProcessing, customFields?: any, filters?: Filter[], dateField?: {
|
|
46
|
+
field: string;
|
|
47
|
+
table: string;
|
|
48
|
+
} | null, rowsOnly?: boolean, rowCountOnly?: boolean) => Promise<{
|
|
42
49
|
columns: ColumnInternal[];
|
|
43
50
|
rows: any[];
|
|
44
51
|
rowCount?: number | undefined;
|
|
45
52
|
error?: string | undefined;
|
|
46
53
|
itemQuery?: string[] | undefined;
|
|
47
54
|
}>;
|
|
48
|
-
export declare const
|
|
55
|
+
export declare const fetchResultsByReport: (reportId: string, client: QuillProviderClient, processing?: AdditionalProcessing, filters?: any, customFields?: any) => Promise<{
|
|
49
56
|
columns: Column[];
|
|
50
57
|
rows: any[];
|
|
51
58
|
rowCount?: number | undefined;
|
|
52
59
|
error?: string | undefined;
|
|
53
60
|
}>;
|
|
54
|
-
export declare const fetchTableByAST: (ast: NodeSQLParser.Select, client:
|
|
61
|
+
export declare const fetchTableByAST: (ast: NodeSQLParser.Select, client: QuillProviderClient, processing?: AdditionalProcessing, customFields?: any, rowsOnly?: boolean, rowCountOnly?: boolean) => Promise<{
|
|
55
62
|
columns: ColumnInternal[];
|
|
56
63
|
rows: any[];
|
|
57
64
|
rowCount?: number | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tableProcessing.d.ts","sourceRoot":"","sources":["../../../src/utils/tableProcessing.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,aAAa,EACd,MAAM,iCAAiC,CAAC;AAEzC,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"tableProcessing.d.ts","sourceRoot":"","sources":["../../../src/utils/tableProcessing.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,aAAa,EACd,MAAM,iCAAiC,CAAC;AAEzC,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAC3D,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAgB5E,MAAM,WAAW,oBAAoB;IACnC,IAAI,CAAC,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC;IAC5C,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,IAAI,CAAC,EAAE,GAAG,CAAC;CACZ;AAED,eAAO,MAAM,cAAc,YAChB,MAAM,EAAE,qBACE,MAAM,EAAE,KAC1B,OAUF,CAAC;AAEF,eAAO,MAAM,wBAAwB,YAC1B,MAAM,EAAE,SACV,MAAM,QACP,GAAG,UACD,mBAAmB,gBACb,GAAG,EAAE;;;;SAmEpB,CAAC;AAEF,eAAO,MAAM,qBAAqB,YACvB,cAAc,EAAE,aACd,MAAM,UACT,GAAG,iBACI,GAAG,yBACK,GAAG,wBACJ,OAAO,UACrB,MAAM,iBA2Cf,CAAC;AAEF,eAAO,MAAM,wBAAwB,YAC1B,cAAc,EAAE,UACjB,mBAAmB,SACpB,MAAM,iBACE,GAAG;;;;EA6DnB,CAAC;AAEF,eAAO,MAAM,kBAAkB,YACpB,MAAM,EAAE,SACV,MAAM,UACL,mBAAmB,gBACb,GAAG,EAAE,KAClB,QAAQ;IACT,eAAe,EAAE,MAAM,EAAE,CAAC;IAC1B,eAAe,EAAE,MAAM,EAAE,GAAG,SAAS,CAAC;CACvC,CAiDA,CAAC;AAkDF,eAAO,MAAM,qBAAqB,YACvB,MAAM,EAAE,SACV,MAAM,UACL,mBAAmB,gBACb,GAAG,EAAE;;mBAEY;YAAE,KAAK,EAAE,IAAI,CAAC;YAAC,GAAG,EAAE,IAAI,CAAA;SAAE;;SAiB1D,CAAC;AA2DF,eAAO,MAAM,gBAAgB,WACnB,mBAAmB,UACnB,MAAM,aACH,MAAM,eACJ,oBAAoB,YACvB,GAAG,iBACE,GAAG,KACjB,QAAQ;IACT,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,IAAI,EAAE,GAAG,EAAE,CAAC;IACZ,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAaA,CAAC;AAEF,eAAO,MAAM,mBAAmB,UACvB,MAAM,UACL,mBAAmB,eACd,oBAAoB,iBAClB,GAAG,YACR,MAAM,EAAE,cACN;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,aACxC,OAAO,iBACH,OAAO;aAEb,cAAc,EAAE;UACnB,GAAG,EAAE;;;;EA2DZ,CAAC;AAEF,eAAO,MAAM,oBAAoB,aACrB,MAAM,UACR,mBAAmB,eACd,oBAAoB,YACvB,GAAG,iBACE,GAAG;aAET,MAAM,EAAE;UACX,GAAG,EAAE;;;EAgFZ,CAAC;AAEF,eAAO,MAAM,eAAe,QACrB,cAAc,MAAM,UACjB,mBAAmB,eACd,oBAAoB,iBAClB,GAAG,aACP,OAAO,iBACH,OAAO;aAEb,cAAc,EAAE;UACnB,GAAG,EAAE;;;;EAyDZ,CAAC;AAEF,eAAO,MAAM,+CAA+C,0BACnC,oBAAoB;;CAU5C,CAAC"}
|
|
@@ -30,7 +30,7 @@ export const getUniqueValuesByColumns = async (columns, query, rows, client, cus
|
|
|
30
30
|
metadata: {
|
|
31
31
|
query: query,
|
|
32
32
|
task: 'query',
|
|
33
|
-
orgId: client.
|
|
33
|
+
orgId: client.organizationId || '*',
|
|
34
34
|
clientId: client.publicKey,
|
|
35
35
|
databaseType: client?.databaseType,
|
|
36
36
|
customFieldsByTable: customFields,
|
|
@@ -67,14 +67,21 @@ export const getUniqueValuesByColumns = async (columns, query, rows, client, cus
|
|
|
67
67
|
}
|
|
68
68
|
return uniqueValues;
|
|
69
69
|
};
|
|
70
|
-
export const getUniqueStringValues = async (columns, tableName, client, customFields, previousUniqueValues) => {
|
|
70
|
+
export const getUniqueStringValues = async (columns, tableName, client, customFields, previousUniqueValues, withExceededColumns, query) => {
|
|
71
71
|
const convertedStringColumns = columns.filter((column) => {
|
|
72
72
|
return isTextColumnType(column.fieldType);
|
|
73
73
|
});
|
|
74
74
|
const stringNames = convertedStringColumns.map((column) => processColumnReference(column.field, client.databaseType));
|
|
75
|
-
const smallStringColumns = await getCountsByColumns(convertedStringColumns, `Select ${stringNames.join(', ')} from ${tableName}`, client, customFields ?? []);
|
|
75
|
+
const { filteredColumns: smallStringColumns, exceededColumns } = await getCountsByColumns(convertedStringColumns, query ?? `Select ${stringNames.join(', ')} from ${tableName}`, client, customFields ?? []);
|
|
76
76
|
const smallStringNames = smallStringColumns.map((column) => processColumnReference(column.field, client.databaseType));
|
|
77
|
-
const newUniqueValues = await getUniqueValuesByColumns(smallStringColumns, `Select ${smallStringNames.join(', ')} from ${tableName}`, [], client, customFields ?? []);
|
|
77
|
+
const newUniqueValues = await getUniqueValuesByColumns(smallStringColumns, query ?? `Select ${smallStringNames.join(', ')} from ${tableName}`, [], client, customFields ?? []);
|
|
78
|
+
if (withExceededColumns) {
|
|
79
|
+
exceededColumns?.forEach((column) => {
|
|
80
|
+
if (newUniqueValues) {
|
|
81
|
+
newUniqueValues[column.field] = { EXCEEDS_LIMIT: true };
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
}
|
|
78
85
|
if (previousUniqueValues) {
|
|
79
86
|
// This logic was used in ReportBuilder before this function was extracted
|
|
80
87
|
// Not sure if it still accurate, but didn't want to remove in case
|
|
@@ -96,7 +103,7 @@ export const getRelevantInfoFromQuery = async (columns, client, query, customFie
|
|
|
96
103
|
});
|
|
97
104
|
const stringNames = convertedStringColumns.map((column) => column.field);
|
|
98
105
|
if (stringNames.length > 0) {
|
|
99
|
-
const smallStringColumns = await getCountsByColumns(convertedStringColumns, query, client, customFields);
|
|
106
|
+
const { filteredColumns: smallStringColumns } = await getCountsByColumns(convertedStringColumns, query, client, customFields);
|
|
100
107
|
uniqueStrings = await getUniqueValuesByColumns(smallStringColumns, query, [], client, customFields);
|
|
101
108
|
}
|
|
102
109
|
const dateColumns = columns.filter((column) => {
|
|
@@ -126,7 +133,7 @@ export const getCountsByColumns = async (columns, query, client, customFields) =
|
|
|
126
133
|
metadata: {
|
|
127
134
|
query: countQuery,
|
|
128
135
|
task: 'query',
|
|
129
|
-
orgId: client.
|
|
136
|
+
orgId: client.organizationId || '*',
|
|
130
137
|
clientId: client.publicKey,
|
|
131
138
|
databaseType: client?.databaseType,
|
|
132
139
|
customFieldsByTable: customFields,
|
|
@@ -136,7 +143,7 @@ export const getCountsByColumns = async (columns, query, client, customFields) =
|
|
|
136
143
|
const cloudBody = { countQuery };
|
|
137
144
|
const data = await getData(client, 'dashquery', 'same-origin', hostedBody, cloudBody);
|
|
138
145
|
if (data.errorMessage) {
|
|
139
|
-
return columns;
|
|
146
|
+
return { filteredColumns: columns, exceededColumns: undefined };
|
|
140
147
|
}
|
|
141
148
|
const results = data.rows.map((columnInfo) => {
|
|
142
149
|
return { field: columnInfo.field, count: columnInfo.count };
|
|
@@ -145,10 +152,14 @@ export const getCountsByColumns = async (columns, query, client, customFields) =
|
|
|
145
152
|
const columnInfo = results.find((result) => result.field === column.field);
|
|
146
153
|
return columnInfo.count <= MAX_PIVOT_UNIQUE_VALUES;
|
|
147
154
|
});
|
|
148
|
-
|
|
155
|
+
const exceededColumns = columns.filter((column) => {
|
|
156
|
+
const columnInfo = results.find((result) => result.field === column.field);
|
|
157
|
+
return columnInfo.count > MAX_PIVOT_UNIQUE_VALUES;
|
|
158
|
+
});
|
|
159
|
+
return { filteredColumns, exceededColumns };
|
|
149
160
|
}
|
|
150
161
|
catch (e) {
|
|
151
|
-
return columns;
|
|
162
|
+
return { filteredColumns: columns, exceededColumns: undefined };
|
|
152
163
|
}
|
|
153
164
|
};
|
|
154
165
|
const fetchDistinctStrings = async (query, client, customFields) => {
|
|
@@ -157,7 +168,7 @@ const fetchDistinctStrings = async (query, client, customFields) => {
|
|
|
157
168
|
metadata: {
|
|
158
169
|
query,
|
|
159
170
|
task: 'query',
|
|
160
|
-
orgId: client.
|
|
171
|
+
orgId: client.organizationId || '*',
|
|
161
172
|
clientId: client.publicKey,
|
|
162
173
|
databaseType: client?.databaseType,
|
|
163
174
|
customFieldsByTable: customFields,
|
|
@@ -200,7 +211,7 @@ const fetchDateRanges = async (query, client, customFields) => {
|
|
|
200
211
|
metadata: {
|
|
201
212
|
query,
|
|
202
213
|
task: 'query',
|
|
203
|
-
orgId: client.
|
|
214
|
+
orgId: client.organizationId || '*',
|
|
204
215
|
clientId: client.publicKey,
|
|
205
216
|
databaseType: client?.databaseType,
|
|
206
217
|
customFieldsByTable: customFields,
|
|
@@ -229,14 +240,14 @@ const fetchDateRanges = async (query, client, customFields) => {
|
|
|
229
240
|
};
|
|
230
241
|
export const getPaginatedRows = async (client, query, reportId, processing, filters, customFields) => {
|
|
231
242
|
if (query) {
|
|
232
|
-
return await
|
|
243
|
+
return await fetchResultsByQuery(query, client, processing, customFields);
|
|
233
244
|
}
|
|
234
245
|
else if (reportId) {
|
|
235
|
-
return await
|
|
246
|
+
return await fetchResultsByReport(reportId, client, processing, filters, customFields);
|
|
236
247
|
}
|
|
237
248
|
return { rows: [], columns: [] };
|
|
238
249
|
};
|
|
239
|
-
export const
|
|
250
|
+
export const fetchResultsByQuery = async (query, client, processing, customFields, filters, dateField, rowsOnly, rowCountOnly) => {
|
|
240
251
|
let rows = [];
|
|
241
252
|
let columns = [];
|
|
242
253
|
let error = undefined;
|
|
@@ -247,14 +258,20 @@ export const fetchTableByQuery = async (query, client, processing, customFields)
|
|
|
247
258
|
metadata: {
|
|
248
259
|
query,
|
|
249
260
|
task: 'query',
|
|
250
|
-
orgId: client.
|
|
261
|
+
orgId: client.organizationId || '*',
|
|
251
262
|
clientId: client.publicKey,
|
|
252
263
|
databaseType: client?.databaseType,
|
|
253
|
-
getCustomFields: !client.
|
|
264
|
+
getCustomFields: !client.organizationId || client.organizationId === '*'
|
|
265
|
+
? false
|
|
266
|
+
: true,
|
|
254
267
|
customFieldsByTable: customFields,
|
|
255
268
|
additionalProcessing: processing,
|
|
256
269
|
useUpdatedDataGathering: processing ? true : false,
|
|
257
270
|
useNewNodeSql: true,
|
|
271
|
+
filters,
|
|
272
|
+
dateField: dateField ?? undefined,
|
|
273
|
+
rowsOnly,
|
|
274
|
+
rowCountOnly,
|
|
258
275
|
},
|
|
259
276
|
};
|
|
260
277
|
const cloudBody = { query };
|
|
@@ -279,7 +296,7 @@ export const fetchTableByQuery = async (query, client, processing, customFields)
|
|
|
279
296
|
}
|
|
280
297
|
return { rows, columns, rowCount, error, itemQuery };
|
|
281
298
|
};
|
|
282
|
-
export const
|
|
299
|
+
export const fetchResultsByReport = async (reportId, client, processing, filters, customFields) => {
|
|
283
300
|
const updatedProcessing = { ...processing };
|
|
284
301
|
let rows = [];
|
|
285
302
|
let columns = [];
|
|
@@ -305,7 +322,7 @@ export const fetchTableByReport = async (reportId, client, processing, filters,
|
|
|
305
322
|
const hostedBody = {
|
|
306
323
|
metadata: {
|
|
307
324
|
dashboardItemId: reportId,
|
|
308
|
-
orgId: client?.
|
|
325
|
+
orgId: client?.organizationId || '*',
|
|
309
326
|
task: 'item',
|
|
310
327
|
filters: minimalFilters,
|
|
311
328
|
clientId: client?.publicKey,
|
|
@@ -352,7 +369,7 @@ export const fetchTableByReport = async (reportId, client, processing, filters,
|
|
|
352
369
|
}
|
|
353
370
|
return { rows, columns, rowCount, error };
|
|
354
371
|
};
|
|
355
|
-
export const fetchTableByAST = async (ast, client, processing, customFields) => {
|
|
372
|
+
export const fetchTableByAST = async (ast, client, processing, customFields, rowsOnly, rowCountOnly) => {
|
|
356
373
|
let rows = [];
|
|
357
374
|
let columns = [];
|
|
358
375
|
let rowCount;
|
|
@@ -364,13 +381,15 @@ export const fetchTableByAST = async (ast, client, processing, customFields) =>
|
|
|
364
381
|
clientId: client.publicKey,
|
|
365
382
|
ast,
|
|
366
383
|
publicKey: client.publicKey,
|
|
367
|
-
orgId: client.
|
|
384
|
+
orgId: client.organizationId || '*',
|
|
368
385
|
task: 'patterns',
|
|
369
386
|
getCustomFields: false,
|
|
370
387
|
customFields,
|
|
371
388
|
additionalProcessing: processing,
|
|
372
389
|
useUpdatedDataGathering: true,
|
|
373
390
|
useNewNodeSql: true,
|
|
391
|
+
rowsOnly,
|
|
392
|
+
rowCountOnly,
|
|
374
393
|
},
|
|
375
394
|
};
|
|
376
395
|
const cloudBody = {};
|