geido commented on code in PR #33656:
URL: https://github.com/apache/superset/pull/33656#discussion_r2124161553


##########
superset-frontend/plugins/plugin-chart-table/src/buildQuery.ts:
##########
@@ -139,22 +141,35 @@ const buildQuery: BuildQuery<TableChartFormData> = (
               timeOffsets,
             )
           : percentMetrics.map(getMetricLabel);
+
         const percentMetricLabels = removeDuplicates(
           percentMetricsLabelsWithTimeComparison,
         );
+
         metrics = removeDuplicates(
           metrics.concat(percentMetrics),
           getMetricLabel,
         );
-        postProcessing = [
-          {
+
+        if (calculationMode === 'all_records') {
+          postProcessing.push({
+            operation: 'contribution_with_totals',
+            options: {
+              columns: percentMetricLabels,
+              rename_columns: percentMetricLabels.map(m => `%${m}`),
+              totals: (formData.extra_form_data as Record<string, any>)
+                ?.contribution_totals?.totals,
+            },
+          } as unknown as PostProcessingRule);

Review Comment:
   What is the reason of forcing this type via `unknown`? Should we tackle the 
typing problem instead?



##########
superset-frontend/plugins/plugin-chart-table/src/buildQuery.ts:
##########
@@ -139,22 +141,35 @@ const buildQuery: BuildQuery<TableChartFormData> = (
               timeOffsets,
             )
           : percentMetrics.map(getMetricLabel);
+
         const percentMetricLabels = removeDuplicates(
           percentMetricsLabelsWithTimeComparison,
         );
+
         metrics = removeDuplicates(
           metrics.concat(percentMetrics),
           getMetricLabel,
         );
-        postProcessing = [
-          {
+
+        if (calculationMode === 'all_records') {

Review Comment:
   Can we use a type for `calculationMode` instead of relying on strings? 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to