Repository: apache/superset
File: superset-frontend/plugins/plugin-chart-ag-grid-table/src/transformProps.ts (TypeScript)

Code before:
  }
  // when pageSize not set, automatically add pagination if too many records
  return numRecords * numColumns > 5000 ? 200 : 0;
};

const transformProps = (
  chartProps: TableChartProps,
): AgGridTableChartTransformedProps => {
  const {
    height,
    width,
    rawFormData: formData,
    queriesData = [],
    ownState: serverPaginationData,
    filterState,
    hooks: { setDataMask = () => {}, onChartStateChange },
    emitCrossFilters,
    theme,
  } = chartProps;

  const {
    include_search: includeSearch = false,
    page_length: pageLength,
    order_desc: sortDesc = false,
    slice_id,
    time_compare,
    comparison_type,
    server_pagination: serverPagination = false,
    server_page_length: serverPageLength = 10,
    query_mode: queryMode,
    align_pn: alignPositiveNegative = true,
    show_cell_bars: showCellBars = true,
    color_pn: colorPositiveNegative = true,
    show_totals: showTotals,
    conditional_formatting: conditionalFormatting,
    comparison_color_enabled: comparisonColorEnabled = false,
    comparison_color_scheme: comparisonColorScheme = ColorSchemeEnum.Green,
  } = formData;

  const allowRearrangeColumns = true;

  // Calculate time comparison settings early since they're used in multiple places
  const isUsingTimeComparison =
    !isEmpty(time_compare) &&
    queryMode === QueryMode.Aggregate &&
    comparison_type === ComparisonType.Values &&
    isFeatureEnabled(FeatureFlag.TableV2TimeComparisonEnabled);

  const nonCustomNorInheritShifts = ensureIsArray(formData.time_compare).filter(
    (shift: string) => shift !== 'custom' && shift !== 'inherit',
  );

Review comment (refactor):
My concern regarding this is that we are going to have the data duplicated, once at the top level of the object and once again in the nested object `extra_form_data`

Code after:
  return numRecords * numColumns > 5000 ? 200 : 0;
};

const transformProps = (
  chartProps: TableChartProps,
): AgGridTableChartTransformedProps => {
  const {
    height,
    width,
    rawFormData: originalFormData,
    queriesData = [],
    ownState: serverPaginationData,
    filterState,
    hooks: { setDataMask = () => {}, onChartStateChange },
    emitCrossFilters,
    theme,
  } = chartProps;

  // Merge extra_form_data (dashboard filter overrides) into formData
  // This ensures dashboard-level settings (like time_compare) override chart-level settings
  // From PRs #33947 and #34014
  const formData = merge(
    {},
    originalFormData,
    originalFormData.extra_form_data,
  );

  const {
    include_search: includeSearch = false,
    page_length: pageLength,
    order_desc: sortDesc = false,
    slice_id,
    time_compare,
    comparison_type,
    server_pagination: serverPagination = false,
    server_page_length: serverPageLength = 10,
    query_mode: queryMode,
    align_pn: alignPositiveNegative = true,
    show_cell_bars: showCellBars = true,
    color_pn: colorPositiveNegative = true,
    show_totals: showTotals,
    conditional_formatting: conditionalFormatting,
    comparison_color_enabled: comparisonColorEnabled = false,
    comparison_color_scheme: comparisonColorScheme = ColorSchemeEnum.Green,
  } = formData;

  const allowRearrangeColumns = true;

  // Calculate time comparison settings early since they're used in multiple places
  const isUsingTimeComparison =
    !isEmpty(time_compare) &&