Skip to content

Commit

Permalink
fix sorting when changing context column
Browse files Browse the repository at this point in the history
  • Loading branch information
bcolloran committed Sep 13, 2023
1 parent 31439f7 commit 28b93f7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
13 changes: 7 additions & 6 deletions web-common/src/features/dashboards/dashboard-stores.ts
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,9 @@ const metricViewReducers = {

setContextColumn(name: string, contextColumn: LeaderboardContextColumn) {
updateMetricsExplorerByName(name, (metricsExplorer) => {
const initialSort = sortTypeForContextColumnType(
metricsExplorer.leaderboardContextColumn
);
switch (contextColumn) {
case LeaderboardContextColumn.DELTA_ABSOLUTE:
case LeaderboardContextColumn.DELTA_PERCENT: {
Expand All @@ -517,13 +520,11 @@ const metricViewReducers = {
metricsExplorer.leaderboardContextColumn = contextColumn;
}

// if we have changed the context column, and the leaderboard is currently
// sorted by the active context column, then we also need to change
// if we have changed the context column, and the leaderboard is
// sorted by the context column from before we made the change,
// then we also need to change
// the sort type to match the new context column
if (
metricsExplorer.dashboardSortType ===
sortTypeForContextColumnType(metricsExplorer.leaderboardContextColumn)
) {
if (metricsExplorer.dashboardSortType === initialSort) {
metricsExplorer.dashboardSortType =
sortTypeForContextColumnType(contextColumn);
}
Expand Down
2 changes: 1 addition & 1 deletion web-common/src/features/dashboards/humanize-numbers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ export function formatProperFractionAsPercent(value): NumberParts {
return formatMeasurePercentageDifference(value);
}

if (value < 0.005 && value !== 0) {
if (value < 0.01 && value !== 0) {
return { percent: "%", int: "<1", dot: "", frac: "", suffix: "" };
} else if (value === 0) {
return { percent: "%", int: "0", dot: "", frac: "", suffix: "" };
Expand Down

0 comments on commit 28b93f7

Please sign in to comment.