From 42e2d7a5798daef6ce5bec5894b27e4e548584a0 Mon Sep 17 00:00:00 2001 From: Mayank Mishra Date: Wed, 3 Dec 2025 13:43:30 +0530 Subject: [PATCH] taking the activity xid in get all submited ques ans --- .../OnBoarding/getAllPQQwithSubmittedAns.ts | 14 ++++++++++---- src/modules/host/services/host.service.ts | 4 ++-- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/modules/host/handlers/Activity_Hub/OnBoarding/getAllPQQwithSubmittedAns.ts b/src/modules/host/handlers/Activity_Hub/OnBoarding/getAllPQQwithSubmittedAns.ts index e7f6bb8..0a61776 100644 --- a/src/modules/host/handlers/Activity_Hub/OnBoarding/getAllPQQwithSubmittedAns.ts +++ b/src/modules/host/handlers/Activity_Hub/OnBoarding/getAllPQQwithSubmittedAns.ts @@ -1,11 +1,9 @@ -import { verifyOnlyMinglarAdminToken } from '@/common/middlewares/jwt/authForOnlyMinglarAdmin'; +import { verifyMinglarAdminHostToken } from '@/common/middlewares/jwt/authForMinglarAdmin&Host'; import { APIGatewayProxyEvent, APIGatewayProxyResult, Context } from 'aws-lambda'; import { PrismaService } from '../../../../../common/database/prisma.service'; import { safeHandler } from '../../../../../common/utils/handlers/safeHandler'; import ApiError from '../../../../../common/utils/helper/ApiError'; -import { PrePopulateService } from '../../../../prepopulate/services/prepopulate.service'; import { HostService } from '../../../services/host.service'; -import { verifyMinglarAdminHostToken } from '@/common/middlewares/jwt/authForMinglarAdmin&Host'; const prismaService = new PrismaService(); const hostService = new HostService(prismaService); @@ -23,7 +21,15 @@ export const handler = safeHandler(async ( // Authenticate user using the shared authForHost function await verifyMinglarAdminHostToken(token); - const result = await hostService.getAllPQQQuesAndSubmittedAns(); + const activity_xid = event.queryStringParameters?.activity_xid + ? Number(event.queryStringParameters.activity_xid) + : null; + + if (!activity_xid) { + throw new ApiError(409, "Activity ID is required") + } + + const result = await hostService.getAllPQQQuesAndSubmittedAns(Number(activity_xid)); return { statusCode: 200, diff --git a/src/modules/host/services/host.service.ts b/src/modules/host/services/host.service.ts index 6b5f159..6f625bb 100644 --- a/src/modules/host/services/host.service.ts +++ b/src/modules/host/services/host.service.ts @@ -1386,9 +1386,9 @@ export class HostService { }) } - async getAllPQQQuesAndSubmittedAns() { + async getAllPQQQuesAndSubmittedAns(activity_xid: number) { return await this.prisma.activityPQQheader.findMany({ - where: { isActive: true }, + where: { isActive: true, activityXid: activity_xid }, include: { pqqQuestions: { select: {