Skip to content

Commit

Permalink
correctly list job ban creators
Browse files Browse the repository at this point in the history
  • Loading branch information
harryob committed Dec 2, 2024
1 parent 7be634e commit 6534964
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 9 deletions.
26 changes: 19 additions & 7 deletions src/player.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,17 +155,29 @@ pub struct JobBan {
ban_time: Option<i64>,
expiration: Option<i64>,
role: String,

#[sqlx(skip)]
banning_admin_ckey: Option<String>,
}

async fn get_player_jobbans(db: &mut MySqlConnection, id: i64) -> Option<Vec<JobBan>> {
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<JobBan> =
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<String> {
Expand Down
4 changes: 2 additions & 2 deletions src/ticket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 6534964

Please sign in to comment.