From 37f14984105e05061fe7a727b354491b387c9f0d Mon Sep 17 00:00:00 2001
From: Li Yi Yu
Date: Wed, 11 Aug 2021 15:35:18 -0400
Subject: [PATCH] Sort insights table total sum (#5521)
Co-authored-by: Paolo D'Amico
---
.../scenes/insights/InsightsTable/InsightsTable.tsx | 12 +++++-------
1 file changed, 5 insertions(+), 7 deletions(-)
diff --git a/frontend/src/scenes/insights/InsightsTable/InsightsTable.tsx b/frontend/src/scenes/insights/InsightsTable/InsightsTable.tsx
index 642a9e486ee..053f82d9235 100644
--- a/frontend/src/scenes/insights/InsightsTable/InsightsTable.tsx
+++ b/frontend/src/scenes/insights/InsightsTable/InsightsTable.tsx
@@ -146,7 +146,7 @@ export function InsightsTable({ isLegend = true, showTotalCount = false }: Insig
if (showTotalCount) {
columns.push({
title: (
-
+
{CALC_COLUMN_LABELS[calcColumnState]}
@@ -163,11 +163,7 @@ export function InsightsTable({ isLegend = true, showTotalCount = false }: Insig
filters.display === ACTIONS_TABLE ||
filters.display === ACTIONS_PIE_CHART)
) {
- // Special handling because `count` will contain the last amount, instead of the cumulative sum.
- return (
- item.aggregated_value?.toLocaleString() ||
- item.data.reduce((acc, val) => acc + val, 0).toLocaleString()
- )
+ return (item.count || item.aggregated_value).toLocaleString()
}
return (
<>
@@ -180,9 +176,11 @@ export function InsightsTable({ isLegend = true, showTotalCount = false }: Insig
>
)
},
+ defaultSortOrder: 'descend',
+ sorter: (a, b) => a.count - b.count,
dataIndex: 'count',
fixed: 'right',
- width: 100,
+ width: 120,
align: 'center',
})
}