Skip to content

Commit

Permalink
Fix meeting creation context bug
Browse files Browse the repository at this point in the history
  • Loading branch information
vcfxb committed Nov 19, 2021
1 parent b3dbf1e commit ae76e48
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
7 changes: 5 additions & 2 deletions graphql/rcos/meetings/creation/context.graphql
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
query CreationContext($host: [uuid!]!, $semester_filter: semesters_bool_exp!) {
query CreationContext($host: [uuid!]!, $today: date!, $include_semesters: [String!]!) {
# Semesters in which a meeting can be created. This will be
# all current and future semesters in ascending order.
available_semesters: semesters(
where: $semester_filter,
where: {_or: [
{end_date: {_gte: $today}},
{semester_id: {_in: $include_semesters}}
]},
order_by: {start_date: asc}
) {
semester_id
Expand Down
9 changes: 2 additions & 7 deletions src/api/rcos/meetings/creation/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,8 @@ impl CreationContext {
) -> Result<creation_context::ResponseData, TelescopeError> {
send_query::<Self>(creation_context::Variables {
host: host.map(|h| vec![h]).unwrap_or(vec![]),
semester_filter: serde_json::from_value(json!({
"_or": [
{ "end_date": { "_gte": Utc::today().naive_utc() }},
{ "semester_id": {"_in": include_semesters }}
]
}))
.map_err(|_| TelescopeError::ise("Malformed semester filter in GraphQL query."))?,
today: Utc::today().naive_utc(),
include_semesters
})
.await
}
Expand Down

0 comments on commit ae76e48

Please sign in to comment.