From d19c1620ab2fa90b1da324cd13ef752263671439 Mon Sep 17 00:00:00 2001 From: pm3512 Date: Sat, 3 Feb 2024 14:02:02 -0500 Subject: [PATCH] added profile expo filtering --- src/_types/augment.d.ts | 4 ++++ src/controllers/CheckInController.ts | 18 ++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/src/_types/augment.d.ts b/src/_types/augment.d.ts index ecb083c..1e15396 100644 --- a/src/_types/augment.d.ts +++ b/src/_types/augment.d.ts @@ -16,6 +16,10 @@ declare global { JWT_SECRET: string; AUTH_TOKEN_EXPIRY: string; MONGODB_URI: string; + JUDGING_URL: string; + JUDGING_TOKEN: string; + // object id for the judging expo checkin item + EXPO_EVENT_ID: string; // Email config EMAIL_HOST?: string; EMAIL_USER?: string; diff --git a/src/controllers/CheckInController.ts b/src/controllers/CheckInController.ts index 0b8fa83..5a1d765 100644 --- a/src/controllers/CheckInController.ts +++ b/src/controllers/CheckInController.ts @@ -13,6 +13,11 @@ import { getPointsPipeline, } from "../aggregations/checkin"; +import { ObjectId } from "bson"; +import Team from "src/models/Team"; +import Project from "src/models/Project"; +import { findUserTeam } from "./TeamController"; + export const recalculatePoints = async ( req: Request, res: Response @@ -273,6 +278,19 @@ export const checkInUser = async ( await checkIn.save(); await profile.save(); + if (item._id.equals(process.env.EXPO_EVENT_ID)) { + // checking into judging expo + const team = await findUserTeam(user._id) + const project = await Project.findOne({ team: team._id }); + const judgingUrl = process.env.JUDGING_URL; + fetch(`${judgingUrl}/checkin?helixProjectId=${project._id}`, { + method: "PUT", + headers: { + authorization: process.env.JUDGING_TOKEN, + }, + }); + } + const json = checkIn.toJSON(); res.json(json); } catch (err) {