Throw out sets containing invalid players

The previous code would keep these sets, but filter out the
invalid players. This has been changed to discard the set entirely.
This commit is contained in:
Kiana Sheibani 2023-09-02 18:55:10 -04:00
parent 1d870362b5
commit 6287c325ef
Signed by: toki
GPG key ID: 6CB106C25E86A9F7

View file

@ -23,7 +23,7 @@ pub struct TournamentSets {
#[arguments(query: {
page: 1,
perPage: 1,
sortBy: "startAt desc",
sortBy: "endAt desc",
filter: {
past: true,
afterDate: $last_query,
@ -144,16 +144,14 @@ impl<'a> QueryUnwrap<TournamentSetsVars<'a>> for TournamentSets {
let teams = set
.slots
.into_iter()
.filter_map(|slot| {
Some(
slot.entrant?
.participants
.into_iter()
.filter_map(|p| Some(p.player?.id?))
.collect(),
)
.map(|slot| {
slot.entrant?
.participants
.into_iter()
.map(|p| p.player?.id)
.try_collect()
})
.collect();
.try_collect()?;
Some(SetResponse { teams, winner })
})
.collect::<Vec<_>>(),