aboutsummaryrefslogtreecommitdiff
path: root/planetwars-server/src/db/matches.rs
diff options
context:
space:
mode:
authorIlion Beyst <ilion.beyst@gmail.com>2022-07-25 22:26:58 +0200
committerIlion Beyst <ilion.beyst@gmail.com>2022-07-25 22:26:58 +0200
commitc30222cf9a5f173f30e5b6193714401dc0e3569f (patch)
tree457a3461a3e2203a8aefaf0b3432a97c22e84101 /planetwars-server/src/db/matches.rs
parent67276bd0bbac15fe087edafd59d164c686509b35 (diff)
downloadplanetwars.dev-c30222cf9a5f173f30e5b6193714401dc0e3569f.tar.xz
planetwars.dev-c30222cf9a5f173f30e5b6193714401dc0e3569f.zip
limit amount of matches used by ranker
Diffstat (limited to 'planetwars-server/src/db/matches.rs')
-rw-r--r--planetwars-server/src/db/matches.rs7
1 files changed, 5 insertions, 2 deletions
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<MatchPlayer>,
}
-pub fn list_matches(conn: &PgConnection) -> QueryResult<Vec<FullMatchData>> {
+pub fn list_matches(amount: i64, conn: &PgConnection) -> QueryResult<Vec<FullMatchData>> {
conn.transaction(|| {
- let matches = matches::table.get_results::<MatchBase>(conn)?;
+ let matches = matches::table
+ .order_by(matches::created_at.desc())
+ .limit(amount)
+ .get_results::<MatchBase>(conn)?;
let match_players = MatchPlayer::belonging_to(&matches)
.left_join(