From c855a156f891ede5ead0a84e126ec3bb3eae2b7b Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Mon, 19 Aug 2024 09:47:20 +0200 Subject: [PATCH] Sort replies to matchmaking based on their choice --- src/interfaces/database/models/matchmaking_choice.rs | 2 +- src/interfaces/database/models/matchmaking_replies.rs | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/interfaces/database/models/matchmaking_choice.rs b/src/interfaces/database/models/matchmaking_choice.rs index 682acc6e..c8c024b3 100644 --- a/src/interfaces/database/models/matchmaking_choice.rs +++ b/src/interfaces/database/models/matchmaking_choice.rs @@ -7,7 +7,7 @@ use diesel::serialize::{IsNull, ToSql}; use super::super::schema::sql_types; -#[derive(Debug, Clone, Copy, PartialEq, FromSqlRow, AsExpression)] +#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, FromSqlRow, AsExpression)] #[diesel(sql_type = sql_types::MatchmakingChoice)] pub enum MatchmakingChoice { Yes, diff --git a/src/interfaces/database/models/matchmaking_replies.rs b/src/interfaces/database/models/matchmaking_replies.rs index fa365e4c..e88692cb 100644 --- a/src/interfaces/database/models/matchmaking_replies.rs +++ b/src/interfaces/database/models/matchmaking_replies.rs @@ -33,6 +33,7 @@ impl MatchmakingReply { .filter(matchmaking_replies::matchmaking_id.eq(matchmaking_id)) .inner_join(users::table.on(matchmaking_replies::user_id.eq(users::id))) .inner_join(telegram::table.on(users::id.eq(telegram::user_id))) + .order_by(matchmaking_replies::choice) .get_results::<(Self, RoyalnetUser, TelegramUser)>(database) .context("Non รจ stato possibile recuperare le risposte al matchmaking dal database RYG.") }