chore: conform linting
ci/woodpecker/push/deploy unknown status Details
ci/woodpecker/push/lint Pipeline was successful Details
ci/woodpecker/push/clippy Pipeline was successful Details
ci/woodpecker/push/build Pipeline was successful Details

dev
Jef Roosens 2023-05-20 21:17:01 +02:00
parent c8ef995bc0
commit fa24625a1f
Signed by: Jef Roosens
GPG Key ID: B75D4F293C7052DB
1 changed files with 9 additions and 16 deletions

View File

@ -50,25 +50,20 @@ pub async fn available(ctx: Context<'_>, date: HumanNaiveDate) -> Result<(), Err
let client = &ctx.data().client;
let date: NaiveDate = date.into();
let mut resources = client
.available(STERRE_BIB_ID, date, 1)
.await?;
let mut resources = client.available(STERRE_BIB_ID, date, 1).await?;
// Cloning here isn't super efficient, but this list only consists of a handful of elements so
// it's fine
resources.sort_by_key(|k| k.resource_name.clone());
ctx.send(|f| {
f.embed(|e| {
e.description(format!(
"Available booking dates for {}.",
date
))
.fields(
resources
.into_iter()
.map(resource_to_embed_field)
.collect::<Vec<EmbedField>>(),
)
e.description(format!("Available booking dates for {}.", date))
.fields(
resources
.into_iter()
.map(resource_to_embed_field)
.collect::<Vec<EmbedField>>(),
)
})
})
.await?;
@ -110,9 +105,7 @@ pub async fn book(
let user = user.unwrap();
let client = &ctx.data().client;
let resources = client
.available(STERRE_BIB_ID, date, 1)
.await?;
let resources = client.available(STERRE_BIB_ID, date, 1).await?;
let chosen_resource = resources
.iter()
.filter(|r| capacity.is_none() || capacity.unwrap() <= r.capacity)