From fd4bfeb193b1623de156779cdbf9ca5f40fbc1ab Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Mon, 19 Aug 2024 08:20:56 +0200 Subject: [PATCH] Fix a couple broken imports --- src/interfaces/database/models/brooch_match.rs | 2 -- .../database/models/matchmaking_events.rs | 8 ++++++-- .../models/matchmaking_messages_telegram.rs | 15 +++++---------- .../database/models/matchmaking_replies.rs | 6 +++--- src/services/telegram/commands/diario.rs | 2 +- src/services/telegram/utils/database.rs | 1 - 6 files changed, 15 insertions(+), 19 deletions(-) diff --git a/src/interfaces/database/models/brooch_match.rs b/src/interfaces/database/models/brooch_match.rs index 96eaba42..2cd73b69 100644 --- a/src/interfaces/database/models/brooch_match.rs +++ b/src/interfaces/database/models/brooch_match.rs @@ -19,7 +19,6 @@ pub struct BroochMatch { impl BroochMatch { pub fn is_flagged(database: &mut PgConnection, match_id: DotaMatchId) -> AnyResult { use crate::interfaces::database::query_prelude::*; - use schema::brooch_match; log::trace!("Checking if {match_id:?} is flagged..."); @@ -35,7 +34,6 @@ impl BroochMatch { pub fn flag(database: &mut PgConnection, match_id: DotaMatchId) -> AnyResult { use crate::interfaces::database::query_prelude::*; - use schema::brooch_match; log::debug!("Flagging {match_id:?} as parsed..."); diff --git a/src/interfaces/database/models/matchmaking_events.rs b/src/interfaces/database/models/matchmaking_events.rs index da53b554..92806047 100644 --- a/src/interfaces/database/models/matchmaking_events.rs +++ b/src/interfaces/database/models/matchmaking_events.rs @@ -1,7 +1,7 @@ use anyhow::Context; -use diesel::{AsExpression, FromSqlRow, Identifiable, Insertable, PgConnection, Queryable, QueryId, Selectable}; +use diesel::{Identifiable, Insertable, PgConnection, Queryable, Selectable}; use diesel::deserialize::FromSql; -use diesel::pg::{Pg, PgValue}; +use diesel::pg::Pg; use diesel::serialize::ToSql; use crate::newtype_sql; @@ -21,6 +21,8 @@ pub struct MatchmakingEvent { impl MatchmakingEvent { /// Create a new [MatchmakingEvent]. pub fn create(database: &mut PgConnection, text: &str, starts_at: &chrono::DateTime) -> AnyResult { + use crate::interfaces::database::query_prelude::*; + insert_into(matchmaking_events::table) .values(&( matchmaking_events::text.eq(text), @@ -32,6 +34,8 @@ impl MatchmakingEvent { /// Retrieve a [MatchmakingEvent] from the database, given its [MatchmakingId]. pub fn get(database: &mut PgConnection, matchmaking_id: MatchmakingId) -> AnyResult { + use crate::interfaces::database::query_prelude::*; + matchmaking_events::table .filter(matchmaking_events::id.eq(matchmaking_id.0)) .get_result::(database) diff --git a/src/interfaces/database/models/matchmaking_messages_telegram.rs b/src/interfaces/database/models/matchmaking_messages_telegram.rs index 19a1a0bb..4c180348 100644 --- a/src/interfaces/database/models/matchmaking_messages_telegram.rs +++ b/src/interfaces/database/models/matchmaking_messages_telegram.rs @@ -20,26 +20,22 @@ pub struct MatchmakingMessageTelegram { #[cfg(feature = "service_telegram")] pub(crate) mod telegram_ext { - use std::cmp::Ordering; use std::str::FromStr; - + use anyhow::Context; - use chrono::DateTime; use chrono::Local; use diesel::PgConnection; use teloxide::payloads::EditMessageTextSetters; use teloxide::payloads::SendMessageSetters; use teloxide::requests::Requester; use teloxide::types::ParseMode; - - use matchmaking_messages_telegram::star; - + use crate::interfaces::database::models::{MatchmakingChoice, MatchmakingId, MatchmakingReply, RoyalnetUser, TelegramUser}; use crate::utils::anyhow_result::AnyResult; use crate::utils::telegram_string::TelegramEscape; - + use super::*; - + #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub enum MatchmakingTelegramKeyboardCallback { Yes, @@ -106,8 +102,7 @@ pub(crate) mod telegram_ext { impl MatchmakingMessageTelegram { /// Get all the [MatchmakingMessageTelegram] for a specific [MatchmakingId]. pub fn get_all(database: &mut PgConnection, matchmaking_id: MatchmakingId) -> AnyResult> { - use diesel::prelude::*; - use crate::interfaces::database::schema::matchmaking_messages_telegram; + use crate::interfaces::database::query_prelude::*; matchmaking_messages_telegram::table .filter(matchmaking_messages_telegram::matchmaking_id.eq(matchmaking_id.0)) diff --git a/src/interfaces/database/models/matchmaking_replies.rs b/src/interfaces/database/models/matchmaking_replies.rs index 401c41c9..fa365e4c 100644 --- a/src/interfaces/database/models/matchmaking_replies.rs +++ b/src/interfaces/database/models/matchmaking_replies.rs @@ -27,7 +27,7 @@ pub struct MatchmakingReply { impl MatchmakingReply { pub fn get_all_telegram(database: &mut PgConnection, matchmaking_id: MatchmakingId) -> AnyResult> { - use schema::{matchmaking_replies, telegram, users}; + use crate::interfaces::database::query_prelude::*; matchmaking_replies::table .filter(matchmaking_replies::matchmaking_id.eq(matchmaking_id)) @@ -38,7 +38,7 @@ impl MatchmakingReply { } pub fn set(database: &mut PgConnection, matchmaking_id: MatchmakingId, user_id: RoyalnetUserId, choice: MatchmakingChoice) -> AnyResult { - use schema::matchmaking_replies; + use crate::interfaces::database::query_prelude::*; insert_into(matchmaking_replies::table) .values(&Self { @@ -58,7 +58,7 @@ impl MatchmakingReply { } pub fn add_late_minutes(database: &mut PgConnection, matchmaking_id: MatchmakingId, user_id: RoyalnetUserId, increase_by: i32) -> AnyResult { - use schema::matchmaking_replies; + use crate::interfaces::database::query_prelude::*; insert_into(matchmaking_replies::table) .values(&Self { diff --git a/src/services/telegram/commands/diario.rs b/src/services/telegram/commands/diario.rs index d75f8f39..f7a34e44 100644 --- a/src/services/telegram/commands/diario.rs +++ b/src/services/telegram/commands/diario.rs @@ -125,7 +125,7 @@ pub async fn handler(bot: &Bot, message: &Message, args: &DiarioArgs, database: }; let entry = { - use schema::diario; + use crate::interfaces::database::query_prelude::*; insert_into(diario::table) .values(&( diff --git a/src/services/telegram/utils/database.rs b/src/services/telegram/utils/database.rs index a46f7a69..04057ae2 100644 --- a/src/services/telegram/utils/database.rs +++ b/src/services/telegram/utils/database.rs @@ -8,7 +8,6 @@ use crate::utils::anyhow_result::AnyResult; impl RoyalnetUser { pub fn from_telegram_userid(database: &mut PgConnection, user_id: UserId) -> AnyResult { use crate::interfaces::database::query_prelude::*; - use schema::{telegram, users}; log::trace!("Retrieving RoyalnetUser with {user_id:?}");