aboutsummaryrefslogtreecommitdiff
path: root/planetwars-server/src/db/matches.rs
diff options
context:
space:
mode:
authorIlion Beyst <ilion.beyst@gmail.com>2022-11-22 20:42:34 +0100
committerIlion Beyst <ilion.beyst@gmail.com>2022-11-22 20:42:34 +0100
commit1eb81092d7a3e7925ae8e4258aa35a009f911b6e (patch)
tree48846d3ecd8741e9d7e9748a8557d89068f32c11 /planetwars-server/src/db/matches.rs
parentb75c0e15dcd93794f7822ff5dfbfda0fe74f7c2a (diff)
downloadplanetwars.dev-1eb81092d7a3e7925ae8e4258aa35a009f911b6e.tar.xz
planetwars.dev-1eb81092d7a3e7925ae8e4258aa35a009f911b6e.zip
add is_ranked attribute to matches
Diffstat (limited to 'planetwars-server/src/db/matches.rs')
-rw-r--r--planetwars-server/src/db/matches.rs5
1 files changed, 4 insertions, 1 deletions
diff --git a/planetwars-server/src/db/matches.rs b/planetwars-server/src/db/matches.rs
index 2aff44b..7af5b4d 100644
--- a/planetwars-server/src/db/matches.rs
+++ b/planetwars-server/src/db/matches.rs
@@ -140,12 +140,15 @@ fn fetch_full_match_data(
}
// TODO: this method should disappear
-pub fn list_matches(amount: i64, conn: &mut PgConnection) -> QueryResult<Vec<FullMatchData>> {
+pub fn fetch_ranked_maps(amount: i64, conn: &mut PgConnection) -> QueryResult<Vec<FullMatchData>> {
conn.transaction(|conn| {
let matches = matches::table
+ .inner_join(maps::table)
.filter(matches::state.eq(MatchState::Finished))
+ .filter(maps::is_ranked.eq(true))
.order_by(matches::created_at.desc())
.limit(amount)
+ .select(matches::all_columns)
.get_results::<MatchBase>(conn)?;
fetch_full_match_data(matches, conn)