Skip to content

Commit

Permalink
Merge branch 'main' of github.com:iforge-uos/ignis
Browse files Browse the repository at this point in the history
  • Loading branch information
Sampiiiii committed May 9, 2024
2 parents c8f2e1b + 9946ebc commit c6bfb99
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ select assert_exists(
@created_at,
@in_person_created_at,
expired := assert_exists((@created_at + .expires_after) < datetime_of_statement()) if exists .expires_after else false,
selectable := (users::User is users::Rep or .rep.id in rep_training.id) and (in_person and exists @in_person_created_at),
selectable := (users::User is users::Rep or .rep.id in rep_training.id) and (.in_person and exists @in_person_created_at),
} filter exists .rep and <training::TrainingLocation>$location_ in .locations
# if they're a rep they can sign in off shift to use the machines they want even if the reps aren't trained
# ideally first comparison should be `__source__ is users::Rep`
Expand Down
47 changes: 21 additions & 26 deletions apps/anvil/dbschema/queries/getUserTrainingForSignIn.query.ts
Original file line number Diff line number Diff line change
@@ -1,38 +1,34 @@
// GENERATED by @edgedb/generate v0.5.3

import type { Executor } from "edgedb";
import type {Executor} from "edgedb";

export type GetUserTrainingForSignInArgs = {
readonly location: "MAINSPACE" | "HEARTSPACE";
readonly on_shift_reasons: ReadonlyArray<string>;
readonly location_: "MAINSPACE" | "HEARTSPACE" | "GEORGE_PORTER";
readonly id: string;
readonly "location": ("MAINSPACE" | "HEARTSPACE");
readonly "on_shift_reasons": ReadonlyArray<string>;
readonly "id": string;
readonly "location_": ("MAINSPACE" | "HEARTSPACE" | "GEORGE_PORTER");
};

export type GetUserTrainingForSignInReturns = {
training: Array<{
id: string;
name: string;
compulsory: boolean;
in_person: boolean;
description: string;
rep: {
id: string;
description: string;
"training": Array<{
"id": string;
"name": string;
"compulsory": boolean;
"in_person": boolean;
"description": string;
"rep": {
"id": string;
"description": string;
} | null;
expired: boolean;
selectable: boolean | null;
"expired": boolean;
"selectable": boolean | null;
"@created_at": Date | null;
"@in_person_created_at": Date | null;
}>;
};

export function getUserTrainingForSignIn(
client: Executor,
args: GetUserTrainingForSignInArgs,
): Promise<GetUserTrainingForSignInReturns> {
return client.queryRequiredSingle(
`\
export function getUserTrainingForSignIn(client: Executor, args: GetUserTrainingForSignInArgs): Promise<GetUserTrainingForSignInReturns> {
return client.queryRequiredSingle(`\
with list := ( # get the on-shift reps
select sign_in::List
filter (
Expand Down Expand Up @@ -64,7 +60,7 @@ select assert_exists(
@created_at,
@in_person_created_at,
expired := assert_exists((@created_at + .expires_after) < datetime_of_statement()) if exists .expires_after else false,
selectable := (users::User is users::Rep or .rep.id in rep_training.id) and (in_person and exists @in_person_created_at),
selectable := (users::User is users::Rep or .rep.id in rep_training.id) and (.in_person and exists @in_person_created_at),
} filter exists .rep and <training::TrainingLocation>$location_ in .locations
# if they're a rep they can sign in off shift to use the machines they want even if the reps aren't trained
# ideally first comparison should be \`__source__ is users::Rep\`
Expand All @@ -77,7 +73,6 @@ select assert_exists(
# select training::Training # TODO reduce the amount of data transferred by storing this similiar to sign in reasons
# filter .id not in user_training.id and exists .rep and <training::TrainingLocation>$location_ in .locations
# ) union user_training.training
# );`,
args,
);
# );`, args);

}

0 comments on commit c6bfb99

Please sign in to comment.