Skip to content

Commit 5216504

Browse files
Frank DenisClaude
Frank Denis
and
Claude
committed
Make monitoring dashboard sorting stable to prevent UI flickering
🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent 5047e9c commit 5216504

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

dnscrypt-proxy/monitoring_ui.go

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,10 @@ func (mc *MetricsCollector) GetMetrics() map[string]interface{} {
346346

347347
// Sort by increasing average response time (faster servers first)
348348
sort.Slice(serverPerfs, func(i, j int) bool {
349-
return serverPerfs[i].avgTime < serverPerfs[j].avgTime
349+
if serverPerfs[i].avgTime != serverPerfs[j].avgTime {
350+
return serverPerfs[i].avgTime < serverPerfs[j].avgTime
351+
}
352+
return serverPerfs[i].name < serverPerfs[j].name
350353
})
351354

352355
// Convert to map for JSON output
@@ -373,7 +376,10 @@ func (mc *MetricsCollector) GetMetrics() map[string]interface{} {
373376

374377
// Sort by decreasing count
375378
sort.Slice(domainCounts, func(i, j int) bool {
376-
return domainCounts[i].count > domainCounts[j].count
379+
if domainCounts[i].count != domainCounts[j].count {
380+
return domainCounts[i].count > domainCounts[j].count
381+
}
382+
return domainCounts[i].domain < domainCounts[j].domain
377383
})
378384

379385
// Take top 20
@@ -405,7 +411,10 @@ func (mc *MetricsCollector) GetMetrics() map[string]interface{} {
405411

406412
// Sort by decreasing count
407413
sort.Slice(queryTypeCounts, func(i, j int) bool {
408-
return queryTypeCounts[i].count > queryTypeCounts[j].count
414+
if queryTypeCounts[i].count != queryTypeCounts[j].count {
415+
return queryTypeCounts[i].count > queryTypeCounts[j].count
416+
}
417+
return queryTypeCounts[i].qtype < queryTypeCounts[j].qtype
409418
})
410419

411420
// Take top 10

0 commit comments

Comments
 (0)