From c30222cf9a5f173f30e5b6193714401dc0e3569f Mon Sep 17 00:00:00 2001 From: Ilion Beyst Date: Mon, 25 Jul 2022 22:26:58 +0200 Subject: limit amount of matches used by ranker --- planetwars-server/src/db/matches.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'planetwars-server/src/db/matches.rs') diff --git a/planetwars-server/src/db/matches.rs b/planetwars-server/src/db/matches.rs index 39b7d9b..061e2ea 100644 --- a/planetwars-server/src/db/matches.rs +++ b/planetwars-server/src/db/matches.rs @@ -87,9 +87,12 @@ pub struct MatchData { pub match_players: Vec, } -pub fn list_matches(conn: &PgConnection) -> QueryResult> { +pub fn list_matches(amount: i64, conn: &PgConnection) -> QueryResult> { conn.transaction(|| { - let matches = matches::table.get_results::(conn)?; + let matches = matches::table + .order_by(matches::created_at.desc()) + .limit(amount) + .get_results::(conn)?; let match_players = MatchPlayer::belonging_to(&matches) .left_join( -- cgit v1.2.3