@quillsql/react 2.16.92 → 2.16.93

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.
Files changed (3) hide show
  1. package/dist/index.cjs +387 -74
  2. package/dist/index.js +387 -74
  3. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -17183,6 +17183,79 @@ var init_paginationProcessing = __esm({
17183
17183
  }
17184
17184
  });
17185
17185
 
17186
+ // src/utils/dashboardProfiler.ts
17187
+ function profilingEnabled() {
17188
+ if (typeof process !== "undefined" && process.env?.QUILL_DASHBOARD_PROFILE === "true") {
17189
+ return true;
17190
+ }
17191
+ if (typeof window === "undefined") return false;
17192
+ return Boolean(window.__QUILL_DASHBOARD_PROFILE__);
17193
+ }
17194
+ function profileStore() {
17195
+ if (typeof window !== "undefined") {
17196
+ const profileWindow = window;
17197
+ profileWindow.__QUILL_DASHBOARD_TRACE__ ??= [];
17198
+ return profileWindow.__QUILL_DASHBOARD_TRACE__;
17199
+ }
17200
+ const globalStore = globalThis;
17201
+ globalStore.__QUILL_DASHBOARD_TRACE__ ??= [];
17202
+ return globalStore.__QUILL_DASHBOARD_TRACE__;
17203
+ }
17204
+ function queryKeyFamily(queryKey) {
17205
+ const head = String(queryKey[0] ?? "");
17206
+ const next = String(queryKey[1] ?? "");
17207
+ if (head === "quill" && next === "dashboard-report") {
17208
+ return "quill/dashboard-report";
17209
+ }
17210
+ if (head === "useReport") {
17211
+ return `useReport/${next || "unknown"}`;
17212
+ }
17213
+ return head || "other";
17214
+ }
17215
+ function summarizeEngineRequest(input) {
17216
+ const metadata = input.metadata ?? {};
17217
+ return {
17218
+ task: input.task ?? null,
17219
+ shareRequest: Boolean(input.shareRequest),
17220
+ reuseExisting: input.reuseExisting ?? null,
17221
+ settled: input.settled ?? null,
17222
+ reportId: metadata.reportId ?? null,
17223
+ metadataKeys: Object.keys(metadata).sort(),
17224
+ dashboardName: metadata.dashboardName ?? null,
17225
+ dashboardItemId: metadata.dashboardItemId ?? null,
17226
+ useNewNodeSql: metadata.useNewNodeSql ?? null,
17227
+ dateBucket: metadata.dateBucket ?? null,
17228
+ hasPivot: Boolean(metadata.pivot),
17229
+ hasReportBuilderState: Boolean(metadata.reportBuilderState),
17230
+ additionalProcessing: metadata.additionalProcessing ?? null,
17231
+ filterCount: Array.isArray(metadata.filters) ? metadata.filters.length : null
17232
+ };
17233
+ }
17234
+ function profileDashboard(event, data) {
17235
+ if (!profilingEnabled()) return;
17236
+ const entry = {
17237
+ at: Math.round(performance.now() * 10) / 10,
17238
+ event,
17239
+ data
17240
+ };
17241
+ profileStore().push(entry);
17242
+ if (typeof window !== "undefined") {
17243
+ const profileWindow = window;
17244
+ profileWindow.__QUILL_DASHBOARD_PROFILE__ = true;
17245
+ profileWindow.__QUILL_DUMP_DASHBOARD_PROFILE__ = () => profileWindow.__QUILL_DASHBOARD_TRACE__ ?? [];
17246
+ }
17247
+ if (typeof process !== "undefined" && process.env?.QUILL_DASHBOARD_PROFILE_CONSOLE === "true" && CONSOLE_EVENT_PATTERN.test(event)) {
17248
+ console.log(`[quill-profile] ${event}`, data ?? {});
17249
+ }
17250
+ }
17251
+ var CONSOLE_EVENT_PATTERN;
17252
+ var init_dashboardProfiler = __esm({
17253
+ "src/utils/dashboardProfiler.ts"() {
17254
+ "use strict";
17255
+ CONSOLE_EVENT_PATTERN = /cache|initial-load|use-report-loading|network|unique-values|table-refresh|pivot|shared-request|engine-fetch|generate-pivot/;
17256
+ }
17257
+ });
17258
+
17186
17259
  // src/utils/pivotConstructor.ts
17187
17260
  function normalizeLegacyPivotSortFieldValue(sortField) {
17188
17261
  if (sortField === void 0) {
@@ -17295,6 +17368,22 @@ async function generatePivotWithSQL({
17295
17368
  rowLimit: pivot.rowLimit,
17296
17369
  dateBucket: resolvedDateBucket
17297
17370
  };
17371
+ profileDashboard(
17372
+ "generate-pivot-sql",
17373
+ summarizeEngineRequest({
17374
+ task: "pivot-template",
17375
+ shareRequest: false,
17376
+ metadata: {
17377
+ reportId: report?.id,
17378
+ dashboardName,
17379
+ dateBucket: resolvedDateBucket,
17380
+ additionalProcessing,
17381
+ pivot: pivotConfig,
17382
+ reportBuilderState,
17383
+ filters: dashboardFilters
17384
+ }
17385
+ })
17386
+ );
17298
17387
  const resp = await quillFetch({
17299
17388
  client,
17300
17389
  task: "pivot-template",
@@ -17673,6 +17762,7 @@ var init_pivotConstructor = __esm({
17673
17762
  init_columnType();
17674
17763
  init_dataFetcher();
17675
17764
  init_dataProcessing();
17765
+ init_dashboardProfiler();
17676
17766
  init_dates();
17677
17767
  init_textProcessing();
17678
17768
  }
@@ -20094,6 +20184,20 @@ async function getOrFetchSharedRequest({
20094
20184
  }) {
20095
20185
  if (signal?.aborted) throw createAbortError(signal);
20096
20186
  let entry = entries.get(key);
20187
+ const reuseExisting = Boolean(entry);
20188
+ profileDashboard("shared-request", {
20189
+ ...summarizeEngineRequest({
20190
+ task: void 0,
20191
+ shareRequest: true,
20192
+ reuseExisting,
20193
+ settled: entry?.settled,
20194
+ metadata: { reportId }
20195
+ }),
20196
+ reportId: reportId ?? null,
20197
+ reuseExisting,
20198
+ settled: entry?.settled ?? false,
20199
+ keyLength: key.length
20200
+ });
20097
20201
  if (!entry) {
20098
20202
  const controller = new AbortController();
20099
20203
  entry = {
@@ -20169,6 +20273,7 @@ var ORPHAN_GRACE_MS, COMPLETED_TTL_MS, entries;
20169
20273
  var init_reportRequestPool = __esm({
20170
20274
  "src/utils/reportRequestPool.ts"() {
20171
20275
  "use strict";
20276
+ init_dashboardProfiler();
20172
20277
  ORPHAN_GRACE_MS = 100;
20173
20278
  COMPLETED_TTL_MS = 15e3;
20174
20279
  entries = /* @__PURE__ */ new Map();
@@ -20731,6 +20836,7 @@ var init_dataFetcher = __esm({
20731
20836
  init_dates();
20732
20837
  init_changelogNotify();
20733
20838
  init_reportRequestPool();
20839
+ init_dashboardProfiler();
20734
20840
  quillFetch = async ({
20735
20841
  client,
20736
20842
  task,
@@ -20791,6 +20897,14 @@ var init_dataFetcher = __esm({
20791
20897
  return { error: "Failed to fetch data" };
20792
20898
  }
20793
20899
  };
20900
+ profileDashboard(
20901
+ "engine-fetch",
20902
+ summarizeEngineRequest({
20903
+ task,
20904
+ shareRequest,
20905
+ metadata
20906
+ })
20907
+ );
20794
20908
  if (!shareRequest) {
20795
20909
  return execute(abortSignal);
20796
20910
  }
@@ -21362,22 +21476,7 @@ init_dates();
21362
21476
  init_pivotConstructor();
21363
21477
  init_columnProcessing();
21364
21478
  init_paginationProcessing();
21365
-
21366
- // src/utils/dashboardProfiler.ts
21367
- function profileDashboard(event, data) {
21368
- if (typeof window === "undefined") return;
21369
- const profileWindow = window;
21370
- if (!profileWindow.__QUILL_DASHBOARD_PROFILE__) return;
21371
- const entry = {
21372
- at: Math.round(performance.now() * 10) / 10,
21373
- event,
21374
- data
21375
- };
21376
- profileWindow.__QUILL_DASHBOARD_TRACE__ ??= [];
21377
- profileWindow.__QUILL_DASHBOARD_TRACE__.push(entry);
21378
- }
21379
-
21380
- // src/utils/dashboard.ts
21479
+ init_dashboardProfiler();
21381
21480
  var defaultDashboardItem = {
21382
21481
  id: "",
21383
21482
  name: "",
@@ -22790,6 +22889,7 @@ init_tableProcessing();
22790
22889
  init_textProcessing();
22791
22890
  init_valueFormatter();
22792
22891
  init_astFilterProcessing();
22892
+ init_dashboardProfiler();
22793
22893
  init_reportBuilder();
22794
22894
  init_astProcessing();
22795
22895
 
@@ -26573,6 +26673,7 @@ function normalizePSTRanges(start, end) {
26573
26673
 
26574
26674
  // src/Context.tsx
26575
26675
  init_changelogNotify();
26676
+ init_dashboardProfiler();
26576
26677
 
26577
26678
  // src/reportStore.ts
26578
26679
  import { createContext, useContext, useSyncExternalStore } from "react";
@@ -32354,7 +32455,7 @@ function QuillTable({
32354
32455
  setSortColumn(sort?.field || "");
32355
32456
  setSortDirection(sort?.direction || "desc");
32356
32457
  }, [sort]);
32357
- const holdFullPageLoader = rows?.length === 0 && isLoading;
32458
+ const holdFullPageLoader = Boolean(isLoading);
32358
32459
  const pageCountUnknown = manualPagination && pageCount === -1;
32359
32460
  const { activeRows, maxPage } = useMemo4(() => {
32360
32461
  const start = currentPage * rowsPerPage;
@@ -37282,6 +37383,7 @@ function getDashboardReportProcessing(report, serverPagination) {
37282
37383
  }
37283
37384
 
37284
37385
  // src/hooks/useDashboard.ts
37386
+ init_dashboardProfiler();
37285
37387
  var DEFAULT_DASHBOARD_REPORT_STALE_TIME_MS = 5 * 60 * 1e3;
37286
37388
  var useDashboardConfigInternal = (dashboardName) => {
37287
37389
  const { dashboardConfig, isLoading: dashboardsLoading } = useContext13(
@@ -38391,6 +38493,14 @@ var useDashboard = (dashboardName, config) => {
38391
38493
  additionalProcessing
38392
38494
  );
38393
38495
  const usePivotTask = !cacheEnabled && !!reportInfo.pivot;
38496
+ profileDashboard("dashboard-report-cache-path", {
38497
+ reportId,
38498
+ cacheEnabled,
38499
+ cacheCabCacheable: cacheCab.isCacheable(reportId),
38500
+ usePivotTask,
38501
+ forceCacheToRefresh,
38502
+ hasPivot: Boolean(reportInfo.pivot)
38503
+ });
38394
38504
  const allFilters = dashboardFilters2.concat(customFilters).concat(customReportFiltersArray);
38395
38505
  const applyInMemoryPivotIfNeeded = (report2) => {
38396
38506
  const pivotToApply = reportInfo.pivot ?? report2.pivot;
@@ -38624,7 +38734,9 @@ var useDashboard = (dashboardName, config) => {
38624
38734
  pivotColumns: pivotData.columns,
38625
38735
  pivotRowCount: pivotData.rowCount,
38626
38736
  pivotQuery: pivotData.pivotQuery,
38627
- comparisonPivotQuery: pivotData.comparisonPivotQuery
38737
+ comparisonPivotQuery: pivotData.comparisonPivotQuery,
38738
+ pivotResultRowField: pivotData.rowField,
38739
+ pivotResultSourceRowField: reportInfo.pivot?.rowField
38628
38740
  },
38629
38741
  error: void 0
38630
38742
  };
@@ -38654,6 +38766,26 @@ var useDashboard = (dashboardName, config) => {
38654
38766
  shareRequest: !forceCacheToRefresh
38655
38767
  });
38656
38768
  };
38769
+ const existingState = queryClient.getQueryState(queryKey);
38770
+ const existingData = queryClient.getQueryData(queryKey);
38771
+ const dataUpdatedAt = existingState?.dataUpdatedAt ?? 0;
38772
+ const ageMs = dataUpdatedAt ? Date.now() - dataUpdatedAt : null;
38773
+ const isStale = dataUpdatedAt === 0 || Date.now() - dataUpdatedAt >= reportStaleTimeMs;
38774
+ profileDashboard("dashboard-report-tanstack-cache", {
38775
+ reportId,
38776
+ keyFamily: "quill/dashboard-report",
38777
+ cacheEnabled,
38778
+ usePivotTask,
38779
+ forceCacheToRefresh,
38780
+ staleTimeMs: reportStaleTimeMs,
38781
+ status: existingState?.status ?? "missing",
38782
+ fetchStatus: existingState?.fetchStatus ?? "idle",
38783
+ hasData: existingData !== void 0,
38784
+ dataUpdatedAt,
38785
+ ageMs,
38786
+ isStale,
38787
+ willReuseTanstack: !forceCacheToRefresh && existingData !== void 0 && !isStale
38788
+ });
38657
38789
  const result = forceCacheToRefresh ? await fetchDashboardReport() : await queryClient.fetchQuery({
38658
38790
  queryKey,
38659
38791
  queryFn: fetchDashboardReport,
@@ -39056,6 +39188,7 @@ var useDashboardReport = (reportId, config) => {
39056
39188
  };
39057
39189
 
39058
39190
  // src/components/Dashboard/DataLoader.tsx
39191
+ init_dashboardProfiler();
39059
39192
  import { Fragment as Fragment5, jsx as jsx46 } from "react/jsx-runtime";
39060
39193
  var constructReportFromItem = (item) => {
39061
39194
  return {
@@ -41471,6 +41604,7 @@ function QuillTableDashboardComponent({
41471
41604
 
41472
41605
  // src/Chart.tsx
41473
41606
  init_valueFormatter();
41607
+ init_dashboardProfiler();
41474
41608
  import { Fragment as Fragment6, jsx as jsx50, jsxs as jsxs38 } from "react/jsx-runtime";
41475
41609
  function Chart({
41476
41610
  colors,
@@ -45462,6 +45596,7 @@ init_Filter();
45462
45596
 
45463
45597
  // src/StaticChart.tsx
45464
45598
  import { useEffect as useEffect20, useMemo as useMemo21 } from "react";
45599
+ init_dashboardProfiler();
45465
45600
  import { jsx as jsx60 } from "react/jsx-runtime";
45466
45601
  var CHART_TYPE_STYLES = {
45467
45602
  metric: { height: "100px", width: "200px" },
@@ -62428,6 +62563,7 @@ function resolveReportFromCacheCab({
62428
62563
  }
62429
62564
 
62430
62565
  // src/hooks/useForm.tsx
62566
+ init_dashboardProfiler();
62431
62567
  init_reportRequestPool();
62432
62568
 
62433
62569
  // src/hooks/useForm.queries.ts
@@ -62473,6 +62609,15 @@ function createUseFormInitialLoadQueryKey(input) {
62473
62609
  input.additionalSchemaHash
62474
62610
  ];
62475
62611
  }
62612
+ var DASHBOARD_REPORT_STALE_TIME_MS = 5 * 60 * 1e3;
62613
+ function findCachedDashboardReportQuery(queryClient, reportId) {
62614
+ const id = String(reportId ?? "").trim();
62615
+ if (!id) return void 0;
62616
+ return queryClient.getQueryCache().findAll({ queryKey: ["quill", "dashboard-report", id] }).find((query) => {
62617
+ const data = query.state.data;
62618
+ return Boolean(data?.report) && !data?.error;
62619
+ });
62620
+ }
62476
62621
  function shouldBootstrapUseFormInitialLoad(input) {
62477
62622
  return !input.hasInitialReportBuilderState && input.previouslyBootstrappedIdentity !== input.currentIdentity;
62478
62623
  }
@@ -63455,6 +63600,11 @@ function getPivotTableSlotReportColumn(reportColumns, aggregations, rowField, pi
63455
63600
  }
63456
63601
  return cols[aggIndex + 1];
63457
63602
  }
63603
+ function pivotRowKey(chart) {
63604
+ return String(
63605
+ chart?.pivotResultRowField ?? chart?.pivot?.rowField ?? ""
63606
+ ).trim();
63607
+ }
63458
63608
  function isPivotTableDateBucketRowAxis(chart, xAxisField) {
63459
63609
  if (!chart?.pivot) return false;
63460
63610
  if (String(chart.chartType ?? "").toLowerCase() !== "table") return false;
@@ -63463,7 +63613,8 @@ function isPivotTableDateBucketRowAxis(chart, xAxisField) {
63463
63613
  }
63464
63614
  const rowField = String(chart.pivot.rowField ?? "").trim();
63465
63615
  const xf = String(xAxisField ?? "").trim();
63466
- if (!rowField || xf !== rowField) return false;
63616
+ const rowKey = pivotRowKey(chart);
63617
+ if (!rowField || xf !== rowField && xf !== rowKey) return false;
63467
63618
  return isDateType(String(chart.pivot.rowFieldType ?? ""));
63468
63619
  }
63469
63620
  var RESOLVABLE_X_AXIS_DATE_BUCKETS = /* @__PURE__ */ new Set([
@@ -63477,22 +63628,24 @@ function resolvePivotDateBucketXAxisFormat(chart, xAxisField) {
63477
63628
  const dateBucket = String(chart?.pivot?.dateBucket ?? "").trim().toLowerCase();
63478
63629
  if (!RESOLVABLE_X_AXIS_DATE_BUCKETS.has(dateBucket)) return null;
63479
63630
  const rowField = String(chart?.pivot?.rowField ?? "").trim();
63480
- if (!rowField || String(xAxisField ?? "").trim() !== rowField) return null;
63631
+ const xf = String(xAxisField ?? "").trim();
63632
+ const rowKey = pivotRowKey(chart);
63633
+ if (!rowField || xf !== rowField && xf !== rowKey) return null;
63481
63634
  if (!isDateType(String(chart?.pivot?.rowFieldType ?? ""))) return null;
63482
63635
  return getDateFormatFromBucket(dateBucket);
63483
63636
  }
63484
63637
  function chartDetailRowsMissingPivotRowBucket(chart) {
63485
63638
  if (!chart?.pivot) return false;
63486
- const rowField = String(chart.pivot.rowField ?? "").trim();
63487
- if (!rowField) return false;
63639
+ const rowKey = pivotRowKey(chart);
63640
+ if (!rowKey) return false;
63488
63641
  const rows = chart.rows;
63489
63642
  if (!Array.isArray(rows) || rows.length === 0) return false;
63490
63643
  const first = rows.find(
63491
63644
  (r) => r && typeof r === "object" && Object.keys(r).length > 0
63492
63645
  );
63493
63646
  if (!first) return false;
63494
- if (!Object.prototype.hasOwnProperty.call(first, rowField)) return true;
63495
- const v = first[rowField];
63647
+ if (!Object.prototype.hasOwnProperty.call(first, rowKey)) return true;
63648
+ const v = first[rowKey];
63496
63649
  return v === void 0 || v === null;
63497
63650
  }
63498
63651
  function shouldUsePivotRowFieldAsXAxis(chartType, pivotRowField, rowColumnFormat) {
@@ -63528,7 +63681,7 @@ function normalizePivotChartForDisplay(chart, resolveTableLabel) {
63528
63681
  } : chart;
63529
63682
  if (!config) return config;
63530
63683
  if (!config.pivot) return config;
63531
- const pivotRowFieldEarly = String(config.pivot?.rowField ?? "").trim();
63684
+ const pivotRowFieldEarly = pivotRowKey(config);
63532
63685
  const rowColumn = (config.pivotColumns ?? config.columns ?? []).find(
63533
63686
  (col) => String(col.field ?? "").trim() === pivotRowFieldEarly
63534
63687
  );
@@ -63551,7 +63704,7 @@ function normalizePivotChartForDisplay(chart, resolveTableLabel) {
63551
63704
  (field) => !INTERNAL_PIVOT_ROW_FIELDS.has(field)
63552
63705
  ) : [];
63553
63706
  const pivotValueFields = pivotRowFields.filter(
63554
- (field) => field !== withResolvedXAxis.pivot?.rowField
63707
+ (field) => field !== pivotRowKey(withResolvedXAxis) && field !== withResolvedXAxis.pivot?.rowField
63555
63708
  );
63556
63709
  const isAggregationOnlyPivot = !String(withResolvedXAxis.pivot?.rowField ?? "").trim() && !String(withResolvedXAxis.pivot?.columnField ?? "").trim();
63557
63710
  const yAxisFormatByField = new Map(
@@ -63668,7 +63821,7 @@ function normalizePivotChartForDisplay(chart, resolveTableLabel) {
63668
63821
  const normalizedPivotColumns = pivotColumnFields.length > 0 ? pivotColumnFields.map((field) => {
63669
63822
  const knownColumn = knownColumnsByField.get(field);
63670
63823
  const yAxis = yAxisFields.find((axis) => axis.field === field);
63671
- const format9 = yAxis?.format ?? knownColumn?.format ?? (field === withResolvedXAxis.pivot?.rowField ? isMetricOrGauge ? "string" : withResolvedXAxis.xAxisFormat ?? "string" : yAxisFallbackFormat);
63824
+ const format9 = yAxis?.format ?? knownColumn?.format ?? (field === pivotRowKey(withResolvedXAxis) || field === withResolvedXAxis.pivot?.rowField ? isMetricOrGauge ? "string" : withResolvedXAxis.xAxisFormat ?? "string" : yAxisFallbackFormat);
63672
63825
  return {
63673
63826
  field,
63674
63827
  label: yAxis?.label ?? knownColumn?.label ?? field,
@@ -63681,7 +63834,7 @@ function normalizePivotChartForDisplay(chart, resolveTableLabel) {
63681
63834
  const slotCol = getPivotTableSlotReportColumn(
63682
63835
  pivotTableSlotColumns,
63683
63836
  aggregations,
63684
- withResolvedXAxis.pivot?.rowField,
63837
+ pivotRowKey(withResolvedXAxis) || withResolvedXAxis.pivot?.rowField,
63685
63838
  col.field
63686
63839
  );
63687
63840
  if (!slotCol) return col;
@@ -63703,9 +63856,7 @@ function normalizePivotChartForDisplay(chart, resolveTableLabel) {
63703
63856
  const normalizedXAxisFormat = normalizedXAxisField === withResolvedXAxis.xAxisField ? withResolvedXAxis.xAxisFormat : yAxisFields.find((axis) => axis.field === normalizedXAxisField)?.format ?? pivotTableDisplayColumns.find(
63704
63857
  (column) => column.field === normalizedXAxisField
63705
63858
  )?.format ?? withResolvedXAxis.xAxisFormat;
63706
- const pivotDisplayRowField = String(
63707
- withResolvedXAxis.pivot?.rowField ?? ""
63708
- ).trim();
63859
+ const pivotDisplayRowField = pivotRowKey(withResolvedXAxis);
63709
63860
  const pivotDisplayRowFieldType = String(
63710
63861
  withResolvedXAxis.pivot?.rowFieldType ?? ""
63711
63862
  ).trim();
@@ -66669,19 +66820,30 @@ function useReport(reportIdArg, options = {}) {
66669
66820
  )
66670
66821
  });
66671
66822
  const diagnostics = globalThis.__QUILL_CACHECAB_DIAGNOSTICS__;
66823
+ const durationMs = performance.now() - startedAt;
66824
+ const outcome = resolution.resolved ? "hit" : "fallback";
66672
66825
  if (Array.isArray(diagnostics)) {
66673
66826
  diagnostics.push({
66674
66827
  reportId: effectiveReportId,
66675
66828
  operation,
66676
- outcome: resolution.resolved ? "hit" : "fallback",
66829
+ outcome,
66677
66830
  reason: resolution.resolved ? "complete" : resolution.reason,
66678
66831
  details: resolution.resolved ? void 0 : resolution.details,
66679
66832
  snapshotReason: snapshot?.reason ?? "cache_miss",
66680
66833
  forcedIncompleteSnapshot: Boolean(snapshot) && !snapshot?.complete && forceIncompleteCacheCabForParity,
66681
66834
  rowCount: snapshot?.rowCount ?? 0,
66682
- durationMs: performance.now() - startedAt
66835
+ durationMs
66683
66836
  });
66684
66837
  }
66838
+ profileDashboard("use-report-cachecab", {
66839
+ reportId: effectiveReportId,
66840
+ operation,
66841
+ outcome,
66842
+ reason: resolution.resolved ? "complete" : resolution.reason,
66843
+ snapshotReason: snapshot?.reason ?? "cache_miss",
66844
+ rowCount: snapshot?.rowCount ?? 0,
66845
+ durationMs: Math.round(durationMs * 10) / 10
66846
+ });
66685
66847
  return resolution.resolved ? resolution.report : null;
66686
66848
  },
66687
66849
  [
@@ -67255,9 +67417,15 @@ function useReport(reportIdArg, options = {}) {
67255
67417
  if (alias) localValues[alias] = values;
67256
67418
  }
67257
67419
  if (hasEveryColumn) {
67420
+ profileDashboard("use-report-unique-values-cachecab-hit", {
67421
+ reportId: effectiveReportId
67422
+ });
67258
67423
  return { uniqueValuesByColumn: localValues };
67259
67424
  }
67260
67425
  }
67426
+ profileDashboard("use-report-unique-values-network", {
67427
+ reportId: effectiveReportId
67428
+ });
67261
67429
  const tablesForUniqueValues = filterUniqueValuesRequest.reportBuilderState?.tables?.map(
67262
67430
  (table2) => String(table2?.name ?? "").trim()
67263
67431
  ) ?? filterUniqueValuesRequest.stringColumnsByTable.map((column) => String(column.table ?? "").trim()).filter(Boolean);
@@ -67776,6 +67944,29 @@ function useReport(reportIdArg, options = {}) {
67776
67944
  const initialLoadQuery = useQuery({
67777
67945
  queryKey: initialLoadQueryKey,
67778
67946
  queryFn: createUseFormQueryFn(async (signal) => {
67947
+ const tanstackState = queryClient.getQueryState(initialLoadQueryKey);
67948
+ const dashboardReportQueries = queryClient.getQueryCache().getAll().filter(
67949
+ (query) => queryKeyFamily(query.queryKey) === "quill/dashboard-report"
67950
+ );
67951
+ const matchingDashboardReport = dashboardReportQueries.find(
67952
+ (query) => String(query.queryKey[2] ?? "") === String(effectiveReportId)
67953
+ );
67954
+ profileDashboard("use-report-initial-load-queryfn", {
67955
+ reportId: effectiveReportId,
67956
+ reason: "TanStack ran this queryFn, so useReport/initial-load had no fresh cached data",
67957
+ keyFamily: "useReport/initial-load",
67958
+ status: tanstackState?.status ?? "missing",
67959
+ hasData: tanstackState?.data !== void 0,
67960
+ dataUpdatedAt: tanstackState?.dataUpdatedAt ?? 0,
67961
+ staleTime: 0,
67962
+ dashboardReportQueryCount: dashboardReportQueries.length,
67963
+ matchingDashboardReport: matchingDashboardReport ? {
67964
+ hasData: matchingDashboardReport.state.data !== void 0,
67965
+ status: matchingDashboardReport.state.status,
67966
+ staleTime: matchingDashboardReport.options?.staleTime ?? 0,
67967
+ unusedByUseReport: true
67968
+ } : null
67969
+ });
67779
67970
  let cachedReportBuilderState = initialReportBuilderStateForLoad ?? void 0;
67780
67971
  if (!cachedReportBuilderState) {
67781
67972
  const snapshot = await cacheCab.getReportSnapshot(
@@ -67800,6 +67991,9 @@ function useReport(reportIdArg, options = {}) {
67800
67991
  operation: "initial"
67801
67992
  });
67802
67993
  if (cachedReport) {
67994
+ profileDashboard("use-report-initial-load-served-from-cachecab", {
67995
+ reportId: effectiveReportId
67996
+ });
67803
67997
  return { report: cachedReport };
67804
67998
  }
67805
67999
  const allowReportTaskBootstrap = shouldBootstrapUseFormInitialLoad({
@@ -67814,6 +68008,12 @@ function useReport(reportIdArg, options = {}) {
67814
68008
  const formFiltersBelongToLoadTarget = Boolean(loadTargetId) && sourceReportIdentity === loadTargetId;
67815
68009
  const rulesForLoad = useInMemoryEngines || !formFiltersBelongToLoadTarget ? EMPTY_QUERY_FILTERS : queryFilters;
67816
68010
  const shareInitialRequest = sharedInitialRequestUsedForReportIdRef.current !== effectiveReportId;
68011
+ profileDashboard("use-report-initial-load-network", {
68012
+ reportId: effectiveReportId,
68013
+ path: "loadReportForUseForm",
68014
+ hasCachedReportBuilderState: Boolean(cachedReportBuilderState)
68015
+ });
68016
+ const networkStartedAt = performance.now();
67817
68017
  const loadResult = await loadReportForUseForm({
67818
68018
  reportId: effectiveReportId,
67819
68019
  initialReportBuilderState: initialReportBuilderStateForLoad,
@@ -67833,6 +68033,12 @@ function useReport(reportIdArg, options = {}) {
67833
68033
  rowsOnly: isCreatedReportBootstrapLoad,
67834
68034
  abortSignal: signal
67835
68035
  });
68036
+ profileDashboard("use-report-initial-load-network-done", {
68037
+ reportId: effectiveReportId,
68038
+ durationMs: Math.round(performance.now() - networkStartedAt),
68039
+ hasReport: Boolean(loadResult.report),
68040
+ error: loadResult.error ?? null
68041
+ });
67836
68042
  if (loadResult.report && !loadResult.error) {
67837
68043
  if (allowReportTaskBootstrap) {
67838
68044
  bootstrapReportTaskUsedForInitialLoadRef.current = initialLoadIdentityHash;
@@ -67844,7 +68050,17 @@ function useReport(reportIdArg, options = {}) {
67844
68050
  return loadResult;
67845
68051
  }),
67846
68052
  enabled: Boolean(effectiveReportId) && Boolean(client) && !reportOverride,
67847
- retry: false
68053
+ retry: false,
68054
+ initialData: () => {
68055
+ const cached = findCachedDashboardReportQuery(
68056
+ queryClient,
68057
+ effectiveReportId
68058
+ );
68059
+ const data = cached?.state.data;
68060
+ return data?.report ? { report: data.report, error: data.error } : void 0;
68061
+ },
68062
+ initialDataUpdatedAt: () => findCachedDashboardReportQuery(queryClient, effectiveReportId)?.state.dataUpdatedAt,
68063
+ staleTime: DASHBOARD_REPORT_STALE_TIME_MS
67848
68064
  });
67849
68065
  const reportNameQueryReportId = String(effectiveReportId ?? "").trim();
67850
68066
  const reportNameQuery = useQuery({
@@ -67895,15 +68111,6 @@ function useReport(reportIdArg, options = {}) {
67895
68111
  const shouldPromoteColumnToRowFromPendingFlag = pendingPromoteColumnToRow && !String(prev.groupRowsBy ?? "").trim();
67896
68112
  const sourceReportBuilderTables = (sourceReport.reportBuilderState?.tables ?? []).filter((table2) => Boolean(String(table2?.name ?? "").trim()));
67897
68113
  const sourceReportBuilderTableNames = sourceReportBuilderTables.map((table2) => table2.name).filter((name2) => Boolean(name2));
67898
- const sourceQueryColumns = normalizeReportBuilderColumns(
67899
- sourceReport.reportBuilderState?.columns ?? (sourceReport.columns ?? []).map((column) => ({
67900
- field: column.field,
67901
- table: column.table ?? resolveColumnTableFromReportMetadata(
67902
- sourceReport,
67903
- column.field
67904
- )
67905
- }))
67906
- );
67907
68114
  const nextQueryFilters = prev.queryFilters.rules.length ? prev.queryFilters : rulesFromReport(sourceReport);
67908
68115
  const pivotAggregationsFromSource = Array.isArray(sourceReport.pivot?.aggregations) ? sourceReport.pivot.aggregations : sourceReport.pivot?.aggregationType ? [
67909
68116
  {
@@ -67970,6 +68177,9 @@ function useReport(reportIdArg, options = {}) {
67970
68177
  tables: tableScopeForDisplayColumns,
67971
68178
  schemaTables: schemaForReportBuilderState
67972
68179
  });
68180
+ const sourceQueryColumns = normalizeReportBuilderColumns(
68181
+ sourceReport.reportBuilderState?.columns?.length ? sourceReport.reportBuilderState.columns : sourceDisplayColumnsFromSchema
68182
+ );
67973
68183
  const savedDisplayColumns = normalizeReportBuilderColumns(
67974
68184
  (sourceReport.columns ?? []).map((column) => ({
67975
68185
  ...column,
@@ -68483,13 +68693,12 @@ function useReport(reportIdArg, options = {}) {
68483
68693
  tables: effectiveReportBuilderState.tables,
68484
68694
  schemaTables: schemaForReportBuilderState
68485
68695
  });
68486
- const columnsToFetch = allColumnsBySelectedTable.length > 0 ? allColumnsBySelectedTable : effectiveReportBuilderState.columns;
68487
- if (columnsToFetch.length === 0) {
68696
+ if (allColumnsBySelectedTable.length === 0) {
68488
68697
  return void 0;
68489
68698
  }
68490
68699
  return {
68491
68700
  ...effectiveReportBuilderState,
68492
- columns: columnsToFetch,
68701
+ columns: allColumnsBySelectedTable,
68493
68702
  pivot: null,
68494
68703
  sort: [],
68495
68704
  limit: null
@@ -68532,6 +68741,29 @@ function useReport(reportIdArg, options = {}) {
68532
68741
  refreshDecision.shouldRefresh,
68533
68742
  queryFilters
68534
68743
  ]);
68744
+ const shouldSkipRedundantPivotTableDataQuery = useMemo33(() => {
68745
+ if (!sourceReport || !pivotState) {
68746
+ return false;
68747
+ }
68748
+ if (tableRefreshVersion !== 0 || pivotRefreshVersion !== 0) {
68749
+ return false;
68750
+ }
68751
+ if (!Array.isArray(sourceReport.rows) || sourceReport.rows.length === 0) {
68752
+ return false;
68753
+ }
68754
+ if (refreshDecision.shouldRefresh) {
68755
+ return false;
68756
+ }
68757
+ const sourceRules = sourceReport.reportBuilderState?.rules ?? EMPTY_QUERY_FILTERS;
68758
+ return stableSerializeForQueryKey(queryFilters) === stableSerializeForQueryKey(sourceRules);
68759
+ }, [
68760
+ sourceReport,
68761
+ pivotState,
68762
+ tableRefreshVersion,
68763
+ pivotRefreshVersion,
68764
+ refreshDecision.shouldRefresh,
68765
+ queryFilters
68766
+ ]);
68535
68767
  const shouldForceTableRefreshFromFilters = !useInMemoryEngines && !pivotState;
68536
68768
  const immediateTableRefreshInput = useMemo33(
68537
68769
  () => ({
@@ -68580,8 +68812,14 @@ function useReport(reportIdArg, options = {}) {
68580
68812
  operation: "table"
68581
68813
  });
68582
68814
  if (cachedReport) {
68815
+ profileDashboard("use-report-table-refresh-cachecab-hit", {
68816
+ reportId: effectiveReportId
68817
+ });
68583
68818
  return { report: cachedReport };
68584
68819
  }
68820
+ profileDashboard("use-report-table-refresh-network", {
68821
+ reportId: effectiveReportId
68822
+ });
68585
68823
  return loadViaReportBuilderState({
68586
68824
  reportId: effectiveReportId,
68587
68825
  reportBuilderState: tableRefreshInput.reportBuilderState,
@@ -69195,7 +69433,8 @@ function useReport(reportIdArg, options = {}) {
69195
69433
  sourceReport
69196
69434
  ]);
69197
69435
  const pivotRefreshQueryEnabled = !reportOverride && pendingPivotRefresh && !shouldSkipPivotRefreshForUnchangedPivot && Boolean(sourceReport) && Boolean(client) && Boolean(effectiveReportBuilderState) && Boolean(nextPivot) && sourceReportMatchesEffectiveReportId;
69198
- const pivotTableDataRefreshQueryEnabled = !reportOverride && Boolean(sourceReport) && Boolean(client) && Boolean(nextPivot) && Boolean(pivotTableDataReportBuilderState) && !pendingPivotRefresh && sourceReportMatchesEffectiveReportId;
69436
+ const initialLoadSettled = Boolean(reportOverride) || !effectiveReportId || Boolean(client) && !initialLoadQuery.isPending && !initialLoadQuery.isFetching;
69437
+ const pivotTableDataRefreshQueryEnabled = !reportOverride && Boolean(sourceReport) && Boolean(client) && Boolean(nextPivot) && Boolean(pivotTableDataReportBuilderState) && !pendingPivotRefresh && sourceReportMatchesEffectiveReportId && initialLoadSettled && !shouldSkipRedundantPivotTableDataQuery;
69199
69438
  const pivotRefreshQuery = useQuery({
69200
69439
  queryKey: createUseFormPivotRefreshQueryKey({
69201
69440
  reportId: effectiveReportId,
@@ -69309,7 +69548,7 @@ function useReport(reportIdArg, options = {}) {
69309
69548
  const paginationRangeStart = pagination.pageIndex * pagination.pageSize;
69310
69549
  const paginationRangeEnd = paginationRangeStart + pagination.pageSize;
69311
69550
  const pageWithinBaseWindow = paginationRangeEnd <= baseWindowRowsLength || trustedSourceRowCount !== void 0 && trustedSourceRowCount <= baseWindowRowsLength;
69312
- const tablePageQueryEnabled = !pageWithinBaseWindow && !reportOverride && !useInMemoryEngines && Boolean(client) && Boolean(sourceReport) && Boolean(tablePageReportBuilderState) && sourceReportMatchesEffectiveReportId && !pendingPivotRefresh;
69551
+ const tablePageQueryEnabled = !pageWithinBaseWindow && !reportOverride && !useInMemoryEngines && Boolean(client) && Boolean(sourceReport) && Boolean(tablePageReportBuilderState) && sourceReportMatchesEffectiveReportId && !pendingPivotRefresh && initialLoadSettled;
69313
69552
  const tablePageQuery = useQuery({
69314
69553
  queryKey: createUseFormTablePageQueryKey({
69315
69554
  reportId: effectiveReportId,
@@ -69481,21 +69720,17 @@ function useReport(reportIdArg, options = {}) {
69481
69720
  if (!sourceReport) return void 0;
69482
69721
  const rowsForChart = Array.isArray(sourceReport.rows) ? sourceReport.rows : [];
69483
69722
  const chartPivot = pendingPivotChangesDimensions ? sourceReport.pivot ?? null : nextPivot ?? (!chartPivotHydratedFromSourceRef.current ? sourceReport.pivot ?? null : null);
69484
- const chartPivotForDisplay = chartPivot && sourceReport.pivotResultRowField && sourceReport.pivotResultSourceRowField === chartPivot.rowField ? {
69485
- ...chartPivot,
69486
- rowField: sourceReport.pivotResultRowField
69487
- } : chartPivot;
69488
- const rowCountForChart = chartPivotForDisplay ? sourceReport.pivotRowCount ?? (Array.isArray(sourceReport.pivotRows) ? sourceReport.pivotRows.length : sourceReport.rowCount) : useInMemoryEngines ? rowsForChart.length : sourceReport.rowCount;
69723
+ const rowCountForChart = chartPivot ? sourceReport.pivotRowCount ?? (Array.isArray(sourceReport.pivotRows) ? sourceReport.pivotRows.length : sourceReport.rowCount) : useInMemoryEngines ? rowsForChart.length : sourceReport.rowCount;
69489
69724
  const referencedTablesForChart = effectiveReportBuilderState?.tables.map((table2) => table2.name).filter((name2) => Boolean(name2));
69490
69725
  const pivotRowsForChart = Array.isArray(sourceReport.pivotRows) ? sourceReport.pivotRows : void 0;
69491
- const rowCountForChartResolved = chartPivotForDisplay ? Array.isArray(pivotRowsForChart) ? pivotRowsForChart.length : rowCountForChart : rowCountForChart;
69726
+ const rowCountForChartResolved = chartPivot ? Array.isArray(pivotRowsForChart) ? pivotRowsForChart.length : rowCountForChart : rowCountForChart;
69492
69727
  const chartDataPayload = {
69493
69728
  ...sourceReport,
69494
69729
  rows: rowsForChart,
69495
69730
  rowCount: rowCountForChartResolved,
69496
69731
  chartType: chartType ?? sourceReport.chartType,
69497
69732
  reportBuilderState: effectiveReportBuilderState,
69498
- pivot: chartPivotForDisplay,
69733
+ pivot: chartPivot,
69499
69734
  referencedTables: referencedTablesForChart && referencedTablesForChart.length > 0 ? referencedTablesForChart : sourceReport.referencedTables,
69500
69735
  pivotRows: pivotRowsForChart,
69501
69736
  pivotColumns: sourceReport.pivotColumns,
@@ -69576,7 +69811,7 @@ function useReport(reportIdArg, options = {}) {
69576
69811
  const xAxisOptions = useMemo33(() => {
69577
69812
  if (!chartAxesBaseChart) return chartAxisOptions;
69578
69813
  const pivot = chartAxesBaseChart.pivot;
69579
- const pivotRowField = String(pivot?.rowField ?? "").trim();
69814
+ const pivotRowField = pivotRowKey(chartAxesBaseChart);
69580
69815
  const chartType2 = String(chartAxesBaseChart.chartType ?? "").toLowerCase();
69581
69816
  if (pivot && pivotRowField) {
69582
69817
  if (["metric", "gauge"].includes(chartType2)) {
@@ -69697,9 +69932,7 @@ function useReport(reportIdArg, options = {}) {
69697
69932
  const resolvedXAxisField = useMemo33(() => {
69698
69933
  if (!chartAxesBaseChart) return "";
69699
69934
  const chartType2 = String(chartAxesBaseChart.chartType ?? "").toLowerCase();
69700
- const pivotRowField = String(
69701
- chartAxesBaseChart.pivot?.rowField ?? ""
69702
- ).trim();
69935
+ const pivotRowField = pivotRowKey(chartAxesBaseChart);
69703
69936
  if (pivotRowField) {
69704
69937
  const rowColumn = (chartAxesBaseChart.pivotColumns ?? chartAxesBaseChart.columns ?? []).find((col) => String(col.field ?? "").trim() === pivotRowField);
69705
69938
  if (shouldUsePivotRowFieldAsXAxis(
@@ -69835,11 +70068,11 @@ function useReport(reportIdArg, options = {}) {
69835
70068
  columns2 = mergePivotTableDisplayColumnLabelsFromYAxis({
69836
70069
  columns: columns2 ?? baseChart.columns,
69837
70070
  yAxisFields: resolvedYAxisFieldsForDisplay,
69838
- pivotRowField: String(baseChart.pivot.rowField ?? ""),
70071
+ pivotRowField: pivotRowKey(baseChart),
69839
70072
  xAxisLabel: resolvedXAxisLabel
69840
70073
  });
69841
70074
  } else {
69842
- const pivotRowField = String(baseChart.pivot.rowField ?? "").trim();
70075
+ const pivotRowField = pivotRowKey(baseChart);
69843
70076
  const pivotLabelByField = new Map(
69844
70077
  (baseChart.pivotColumns ?? []).map((column) => [
69845
70078
  String(column.field ?? "").trim(),
@@ -69904,7 +70137,10 @@ function useReport(reportIdArg, options = {}) {
69904
70137
  const key = String(raw);
69905
70138
  const timestamp = new Date(key).getTime();
69906
70139
  if (Number.isNaN(timestamp)) continue;
69907
- labelsByRaw.set(key, String(record[rowField] ?? key));
70140
+ labelsByRaw.set(
70141
+ key,
70142
+ String(record[pivotRowKey(chart)] ?? record[rowField] ?? key)
70143
+ );
69908
70144
  const cachedMin = pivotDateFilterRangeCacheRef.current.min;
69909
70145
  const cachedMax = pivotDateFilterRangeCacheRef.current.max;
69910
70146
  if (cachedMin == null || timestamp < new Date(cachedMin).getTime()) {
@@ -70205,9 +70441,7 @@ function useReport(reportIdArg, options = {}) {
70205
70441
  sourceReport,
70206
70442
  includeSelectedSchemaFallback: tableColumnsEditedSignature !== null
70207
70443
  });
70208
- const pivotRowFieldForTable = String(
70209
- sourceReport?.pivot?.rowField ?? ""
70210
- ).trim();
70444
+ const pivotRowFieldForTable = pivotRowKey(sourceReport);
70211
70445
  const pivotRowTableUsesAxisFormat = chartAxisEdits.xAxisFormat !== void 0;
70212
70446
  const columns2 = String(chartType ?? "").toLowerCase() === "table" && sourceReport?.pivot && pivotRowFieldForTable && String(resolvedXAxisField ?? "").trim() === pivotRowFieldForTable ? mergedFromReport.map(
70213
70447
  (column) => column.field === pivotRowFieldForTable ? {
@@ -70219,7 +70453,7 @@ function useReport(reportIdArg, options = {}) {
70219
70453
  const pivotLabeledColumns = String(chartType ?? "").toLowerCase() === "table" && sourceReport?.pivot ? mergePivotTableDisplayColumnLabelsFromYAxis({
70220
70454
  columns: columns2,
70221
70455
  yAxisFields: resolvedYAxisFieldsForDisplay,
70222
- pivotRowField: String(sourceReport.pivot.rowField ?? ""),
70456
+ pivotRowField: pivotRowKey(sourceReport),
70223
70457
  xAxisLabel: resolvedXAxisLabel
70224
70458
  }) ?? columns2 : columns2;
70225
70459
  const tableColumnsWithPivotDisplayLabels = pivotLabeledColumns.map(
@@ -70468,7 +70702,7 @@ function useReport(reportIdArg, options = {}) {
70468
70702
  if (slotFormatting) {
70469
70703
  const aggregations = slotFormatting.aggregations;
70470
70704
  const hasMultiple = aggregations.length > 1;
70471
- const rowField = String(pivotState?.rowField ?? "").trim();
70705
+ const rowField = pivotRowKey(chart);
70472
70706
  const firstValueColumnFormat = String(
70473
70707
  (chart.columns ?? []).find(
70474
70708
  (c) => String(c.field ?? "").trim() !== rowField
@@ -70504,9 +70738,7 @@ function useReport(reportIdArg, options = {}) {
70504
70738
  }
70505
70739
  }
70506
70740
  }
70507
- const pivotRowFieldForSettings = String(
70508
- chart?.pivot?.rowField ?? ""
70509
- ).trim();
70741
+ const pivotRowFieldForSettings = pivotRowKey(chart);
70510
70742
  const rowAxisLabel = String(resolvedXAxisLabel ?? "").trim();
70511
70743
  for (const columnId of activeTableColumnIds) {
70512
70744
  const option = columnOptionById.get(columnId);
@@ -70566,7 +70798,7 @@ function useReport(reportIdArg, options = {}) {
70566
70798
  tableColumnSettingsCoalesceRef.current = new Map(tableColumnSettingsById);
70567
70799
  }, [tableColumnSettingsById]);
70568
70800
  const tableColumnItems = useMemo33(() => {
70569
- const pivotRowFieldForFormat = String(chart?.pivot?.rowField ?? "").trim();
70801
+ const pivotRowFieldForFormat = pivotRowKey(chart);
70570
70802
  const pivotRowFieldType = String(chart?.pivot?.rowFieldType ?? "").trim();
70571
70803
  const items = activeTableColumnIds.map((columnId) => {
70572
70804
  const option = columnOptionById.get(columnId);
@@ -70605,7 +70837,7 @@ function useReport(reportIdArg, options = {}) {
70605
70837
  return new Map(tableColumnItems.map((item) => [item.id, item]));
70606
70838
  }, [tableColumnItems]);
70607
70839
  const tableColumnValues = useMemo33(() => {
70608
- const pivotRowFieldForFormat = String(chart?.pivot?.rowField ?? "").trim();
70840
+ const pivotRowFieldForFormat = pivotRowKey(chart);
70609
70841
  const pivotRowFieldType = String(chart?.pivot?.rowFieldType ?? "").trim();
70610
70842
  return tableColumnItems.map((item) => {
70611
70843
  const coerced = coerceTableColumnFormatToAxisValue(item.format);
@@ -70626,8 +70858,89 @@ function useReport(reportIdArg, options = {}) {
70626
70858
  const initialLoadInProgress = !reportOverride && Boolean(effectiveReportId) && (!client || initialLoadQuery.isPending || initialLoadQuery.isFetching);
70627
70859
  const filterUniqueValuesLoading = filterUniqueValuesEnabled && (filterUniqueValuesQuery.isPending || filterUniqueValuesQuery.isFetching);
70628
70860
  const chartLoading = initialLoadInProgress || pendingPivotRefresh || (Boolean(nextPivot) ? pivotRefreshQuery.isFetching : tableRefreshQuery.isFetching);
70629
- const tableLoading = initialLoadInProgress || pendingPivotRefresh || tablePageFetching || (Boolean(nextPivot) ? pivotTableDataRefreshQuery.isFetching : tableRefreshQuery.isFetching);
70861
+ const awaitingPivotDetailRows = Boolean(nextPivot || sourceReport?.pivot) && !reportOverride && Boolean(sourceReport) && sourceReportMatchesEffectiveReportId && (!Array.isArray(sourceReport?.rows) || sourceReport.rows.length === 0) && pivotTableDataRefreshQuery.status !== "error";
70862
+ const tableLoading = initialLoadInProgress || pendingPivotRefresh || awaitingPivotDetailRows || tablePageFetching && pagination.pageIndex > 0 || (Boolean(nextPivot) ? pivotTableDataRefreshQuery.isFetching : tableRefreshQuery.isFetching);
70630
70863
  const loading = chartLoading || tableLoading;
70864
+ const lastUseReportLoadingLogRef = useRef24("");
70865
+ useEffect33(() => {
70866
+ const snapshot = {
70867
+ reportId: effectiveReportId,
70868
+ chartLoading,
70869
+ tableLoading,
70870
+ loading,
70871
+ initialLoadInProgress,
70872
+ initialLoad: {
70873
+ status: initialLoadQuery.status,
70874
+ fetchStatus: initialLoadQuery.fetchStatus,
70875
+ isPending: initialLoadQuery.isPending,
70876
+ isFetching: initialLoadQuery.isFetching,
70877
+ hasData: initialLoadQuery.data !== void 0,
70878
+ dataUpdatedAt: initialLoadQuery.dataUpdatedAt,
70879
+ staleTime: 0
70880
+ },
70881
+ pendingPivotRefresh,
70882
+ pivotRefresh: {
70883
+ enabled: pivotRefreshQueryEnabled,
70884
+ isFetching: pivotRefreshQuery.isFetching
70885
+ },
70886
+ tableRefresh: {
70887
+ enabled: tableRefreshQueryEnabled,
70888
+ isFetching: tableRefreshQuery.isFetching
70889
+ },
70890
+ pivotTableData: {
70891
+ enabled: pivotTableDataRefreshQueryEnabled,
70892
+ isFetching: pivotTableDataRefreshQuery.isFetching
70893
+ },
70894
+ tablePage: {
70895
+ enabled: tablePageQueryEnabled,
70896
+ isFetching: tablePageQuery.isFetching
70897
+ },
70898
+ uniqueValues: {
70899
+ enabled: filterUniqueValuesEnabled,
70900
+ isFetching: filterUniqueValuesQuery.isFetching,
70901
+ isPending: filterUniqueValuesQuery.isPending
70902
+ },
70903
+ whyChartLoading: {
70904
+ noClient: !client,
70905
+ initialPending: initialLoadQuery.isPending,
70906
+ initialFetching: initialLoadQuery.isFetching,
70907
+ pendingPivotRefresh,
70908
+ pivotRefreshFetching: Boolean(nextPivot) && pivotRefreshQuery.isFetching,
70909
+ tableRefreshFetching: !nextPivot && tableRefreshQuery.isFetching
70910
+ }
70911
+ };
70912
+ const serialized = JSON.stringify(snapshot);
70913
+ if (serialized === lastUseReportLoadingLogRef.current) return;
70914
+ lastUseReportLoadingLogRef.current = serialized;
70915
+ profileDashboard("use-report-loading", snapshot);
70916
+ }, [
70917
+ client,
70918
+ chartLoading,
70919
+ effectiveReportId,
70920
+ filterUniqueValuesEnabled,
70921
+ filterUniqueValuesQuery.fetchStatus,
70922
+ filterUniqueValuesQuery.isFetching,
70923
+ filterUniqueValuesQuery.isPending,
70924
+ initialLoadInProgress,
70925
+ initialLoadQuery.data,
70926
+ initialLoadQuery.dataUpdatedAt,
70927
+ initialLoadQuery.fetchStatus,
70928
+ initialLoadQuery.isFetching,
70929
+ initialLoadQuery.isPending,
70930
+ initialLoadQuery.status,
70931
+ loading,
70932
+ nextPivot,
70933
+ pendingPivotRefresh,
70934
+ pivotRefreshQuery.isFetching,
70935
+ pivotRefreshQueryEnabled,
70936
+ pivotTableDataRefreshQuery.isFetching,
70937
+ pivotTableDataRefreshQueryEnabled,
70938
+ tableLoading,
70939
+ tablePageQuery.isFetching,
70940
+ tablePageQueryEnabled,
70941
+ tableRefreshQuery.isFetching,
70942
+ tableRefreshQueryEnabled
70943
+ ]);
70631
70944
  const buildSetReportColumnsFromIds = (nextColumnIds, settingsById) => {
70632
70945
  const normalizedNextIds = nextColumnIds.map((columnId) => String(columnId ?? "").trim()).filter(Boolean);
70633
70946
  return normalizedNextIds.map((columnId) => {
@@ -70667,7 +70980,7 @@ function useReport(reportIdArg, options = {}) {
70667
70980
  const option = columnOptionById.get(normalizedId);
70668
70981
  const pivotField = String(option?.field ?? normalizedId).trim();
70669
70982
  const pivotModel = chartAxesBaseChart.pivot;
70670
- const rowField = String(pivotModel?.rowField ?? "").trim();
70983
+ const rowField = pivotRowKey(chartAxesBaseChart);
70671
70984
  if (!pivotModel) return null;
70672
70985
  const isPivotRowColumn = Boolean(
70673
70986
  pivotField && rowField && pivotField === rowField