diff --git a/src/player.rs b/src/player.rs index 97ff434..30b0807 100644 --- a/src/player.rs +++ b/src/player.rs @@ -155,17 +155,29 @@ pub struct JobBan { ban_time: Option, expiration: Option, role: String, + + #[sqlx(skip)] + banning_admin_ckey: Option, } async fn get_player_jobbans(db: &mut MySqlConnection, id: i64) -> Option> { - match query_as("SELECT * FROM player_job_bans WHERE player_id = ?") - .bind(id) - .fetch_all(db) - .await - { - Ok(jobbans) => Some(jobbans), - Err(err) => panic!("{err:?}"), + let mut jobbans: Vec = + match query_as("SELECT * FROM player_job_bans WHERE player_id = ?") + .bind(id) + .fetch_all(&mut *db) + .await + { + Ok(jobbans) => jobbans, + Err(err) => panic!("{err:?}"), + }; + + for jobban in &mut jobbans.iter_mut() { + if jobban.admin_id.is_some() { + jobban.banning_admin_ckey = get_player_ckey(&mut *db, jobban.admin_id.unwrap()).await; + } } + + Some(jobbans) } async fn get_discord_id_from_player_id(db: &mut MySqlConnection, id: i64) -> Option { diff --git a/src/ticket.rs b/src/ticket.rs index a4a23f1..76c2c41 100644 --- a/src/ticket.rs +++ b/src/ticket.rs @@ -53,8 +53,8 @@ pub async fn get_tickets_by_user( if from.is_some() && to.is_some() { rows = query("SELECT DISTINCT round_id, ticket FROM ticket WHERE (sender = ? OR recipient = ?) AND (time >= ? AND time <= ?) ORDER BY round_id DESC LIMIT 15 OFFSET ?") - .bind(&ckey) - .bind(&ckey) + .bind(ckey) + .bind(ckey) .bind(from.unwrap()) .bind(to.unwrap()) .bind(offset)