sort popularity_contest rows descending by request counts

This commit is contained in:
Bryan Stitt 2023-03-02 18:33:17 +00:00
parent d1b955275d
commit c7b74e1795

View File

@ -1,4 +1,4 @@
use std::collections::BTreeMap; use std::{cmp::Reverse, collections::BTreeMap};
// show what nodes are used most often // show what nodes are used most often
use argh::FromArgs; use argh::FromArgs;
@ -102,9 +102,11 @@ impl PopularityContestSubCommand {
let total_requests = total_requests as f32; let total_requests = total_requests as f32;
for (tier, rpcs) in by_tier.iter() { for (tier, rpcs) in by_tier.iter_mut() {
let t = (*tier_requests.get(tier).unwrap()) as f32; let t = (*tier_requests.get(tier).unwrap()) as f32;
rpcs.sort_by_cached_key(|x| Reverse(x.requests));
for rpc in rpcs.iter() { for rpc in rpcs.iter() {
let tier_request_pct = if t == 0.0 { let tier_request_pct = if t == 0.0 {
0.0 0.0