Skip to content
This repository was archived by the owner on Nov 7, 2025. It is now read-only.

Commit 18b8f96

Browse files
authored
Stop flickering of top errors (#1000)
Problem, our dashboard flickers due to undefined order if count is exact: https://github.com/user-attachments/assets/6b1e5ba3-d219-4b21-b527-adac006dabb6 It looks poorly on demos.
1 parent d7ac5fa commit 18b8f96

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

quesma/stats/errorstats/error_statistics.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,12 @@ func (e *ErrorStatisticsStore) ReturnTopErrors(count int) []ErrorStatistics {
107107

108108
// Sort by count
109109
sort.Slice(errorStatistics, func(i, j int) bool {
110-
return errorStatistics[i].Count > errorStatistics[j].Count
110+
if errorStatistics[i].Count == errorStatistics[j].Count {
111+
// We need stable ordering if we have exact match on count
112+
return errorStatistics[i].Reason < errorStatistics[j].Reason
113+
} else {
114+
return errorStatistics[i].Count > errorStatistics[j].Count
115+
}
111116
})
112117

113118
// Return top 5

0 commit comments

Comments
 (0)