Add player names to tournament query

This commit is contained in:
Kiana Sheibani 2023-09-23 00:11:53 -04:00
parent fe4f82daeb
commit 6ce463b529
Signed by: toki
GPG key ID: 6CB106C25E86A9F7

View file

@ -91,6 +91,8 @@ struct Participant {
#[derive(cynic::QueryFragment, Debug)] #[derive(cynic::QueryFragment, Debug)]
struct Player { struct Player {
id: Option<PlayerId>, id: Option<PlayerId>,
gamer_tag: Option<String>,
prefix: Option<String>,
} }
// Unwrap // Unwrap
@ -105,6 +107,12 @@ pub struct SetData {
pub winner: usize, pub winner: usize,
} }
pub struct PlayerData {
pub id: PlayerId,
pub gamer_tag: Option<String>,
pub prefix: Option<String>,
}
impl<'a> QueryUnwrap<TournamentSetsVars<'a>> for TournamentSets { impl<'a> QueryUnwrap<TournamentSetsVars<'a>> for TournamentSets {
type Unwrapped = Vec<TournamentData>; type Unwrapped = Vec<TournamentData>;
@ -142,7 +150,14 @@ impl<'a> QueryUnwrap<TournamentSetsVars<'a>> for TournamentSets {
slot.entrant? slot.entrant?
.participants .participants
.into_iter() .into_iter()
.map(|p| p.player?.id) .map(|p| {
let p_ = p.player?;
Some(PlayerData {
id: p_.id?,
gamer_tag: p_.gamer_tag,
prefix: p_.prefix,
})
})
.try_collect() .try_collect()
}) })
.try_collect()?; .try_collect()?;