Skip to content

Commit

Permalink
feat: Exclude existing pupils from requiring a screening
Browse files Browse the repository at this point in the history
We use matches / course participation to exlude existing active pupils from needing a screening
  • Loading branch information
Jonas Wilms committed Jan 22, 2024
1 parent 02d1259 commit 0fc2857
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion graphql/roles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,13 @@ export async function evaluatePupilRoles(pupil: Pupil, roles: Role[]) {
}

if (process.env.REQUIRE_PUPIL_SCREENING === 'true') {
// From Q1 2024 onwards we require pupils to be screened before they can join courses or get a match
const wasSuccessfullyScreened = (await prisma.pupil_screening.count({ where: { pupilId: pupil.id, status: 'success' } })) > 0;
if (!wasSuccessfullyScreened) {
// Pupils that registered before and were not yet screened can continue to use the app as they used to
const alreadyHasMatch = (await prisma.match.count({ where: { pupilId: pupil.id } })) > 0;
const alreadyJoinedCourse = (await prisma.subcourse_participants_pupil.count({ where: { pupilId: pupil.id } })) > 0;

if (!wasSuccessfullyScreened && !alreadyHasMatch && !alreadyJoinedCourse) {
logger.info(`Pupil(${pupil.id}) was not yet successfully screened, no roles granted`);
return;
}
Expand Down

0 comments on commit 0fc2857

Please sign in to comment.