fix(api): sort shards by shard_id

This commit is contained in:
alyssa 2024-12-24 04:22:24 +00:00
parent 643c494ffb
commit fd6909cd96

View file

@ -14,7 +14,7 @@ struct ClusterStats {
}
pub async fn discord_state(State(ctx): State<ApiContext>) -> Json<Value> {
let shard_status = ctx
let mut shard_status = ctx
.redis
.hgetall::<HashMap<String, String>, &str>("pluralkit:shardstatus")
.await
@ -23,6 +23,8 @@ pub async fn discord_state(State(ctx): State<ApiContext>) -> Json<Value> {
.map(|v| serde_json::from_str(v).expect("could not deserialize shard"))
.collect::<Vec<ShardState>>();
shard_status.sort_by(|a, b| a.shard_id.cmp(&b.shard_id));
Json(json!({
"shards": shard_status,
}))