Skip to content

Commit 6db5ce9

Browse files
committed
feat: sort by score in /stats
1 parent 5120785 commit 6db5ce9

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/commands.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -365,14 +365,17 @@ async fn authorizations(bot: Bot, msg: Message, db: Arc<SqlitePool>) -> HandlerR
365365
}
366366

367367
async fn stats(bot: Bot, msg: Message, db: Arc<SqlitePool>) -> HandlerResult {
368-
let committee = sqlx::query!(r#"SELECT * FROM committee"#)
368+
let mut committee = sqlx::query!(r#"SELECT * FROM committee"#)
369369
.fetch_all(db.as_ref())
370370
.await?;
371371

372+
committee.sort_by_key(|r| r.poll_count);
373+
372374
bot.send_message(
373375
msg.chat.id,
374376
committee
375377
.into_iter()
378+
.rev()
376379
.map(|c| format!("- {} (polls: {})", c.name.unwrap_or_default(), c.poll_count))
377380
.collect::<Vec<_>>()
378381
.join("\n"),

0 commit comments

Comments
 (0)