Made view more api for upper section and host pq redirectiion through mail

This commit is contained in:
2026-02-23 19:49:05 +05:30
parent aa3e6fd3d1
commit b22324539a
9 changed files with 215 additions and 11 deletions

View File

@@ -850,7 +850,7 @@ model HostSuggestion {
id Int @id @default(autoincrement())
hostXid Int @map("host_xid")
host HostHeader @relation(fields: [hostXid], references: [id], onDelete: Cascade)
title String @map("title") @db.VarChar(20)
title String @map("title") @db.VarChar(50)
comments String @map("comments") @db.VarChar(200)
isparent Boolean @default(false) @map("is_parent")
isreviewed Boolean @default(false) @map("is_reviewed")

View File

@@ -58,6 +58,7 @@ provider:
MINGLAR_ADMIN_EMAIL: ${env:MINGLAR_ADMIN_EMAIL}
AM_INVITATION_LINK: ${env:AM_INVITATION_LINK}
HOST_LINK: ${env:HOST_LINK}
HOST_LINK_PQ: ${env:HOST_LINK_PQ}
iam:
role:

View File

@@ -302,3 +302,18 @@ viewMoreActivitiesByInterest:
- httpApi:
path: /user/activities/view-more-activities
method: get
viewMoreActivitiesUpperSection:
handler: src/modules/user/handlers/activities/viewMoreUpperSection.handler
memorySize: 384
package:
patterns:
- 'src/modules/user/handlers/activities/**'
- ${file(./serverless/patterns/base.yml):pattern1}
- ${file(./serverless/patterns/base.yml):pattern2}
- ${file(./serverless/patterns/base.yml):pattern3}
- ${file(./serverless/patterns/base.yml):pattern4}
events:
- httpApi:
path: /user/activities/view-more-activities-upper-section
method: get

View File

@@ -83,7 +83,8 @@ const envVarsSchema = yup
BYPASS_OTP: yup.boolean().default(false).required('Bypass OTP is required'),
// Email links
AM_INVITATION_LINK: yup.string().required('Link to send in AM invitation mail is required'),
HOST_LINK: yup.string().required('Link to host panel is required')
HOST_LINK: yup.string().required('Link to host panel is required'),
HOST_LINK_PQ: yup.string().required('Link to host panel pqp is required')
})
.noUnknown(true);
@@ -163,6 +164,7 @@ function getConfig() {
MinglarAdminName: envVars.MINGLAR_ADMIN_NAME,
AM_INVITATION_LINK: envVars.AM_INVITATION_LINK,
HOST_LINK: envVars.HOST_LINK,
HOST_LINK_PQ: envVars.HOST_LINK_PQ,
// oneSignal: {
// appID: envVars.ONESIGNAL_APPID,
// restApiKey: envVars.ONESIGNAL_REST_APIKEY,

View File

@@ -1,12 +1,10 @@
import { APIGatewayProxyEvent, APIGatewayProxyResult, Context } from 'aws-lambda';
import { safeHandler } from '../../../../../common/utils/handlers/safeHandler';
import { prismaClient } from '../../../../../common/database/prisma.lambda.service';
import { verifyHostToken } from '../../../../../common/middlewares/jwt/authForHost';
import { safeHandler } from '../../../../../common/utils/handlers/safeHandler';
import ApiError from '../../../../../common/utils/helper/ApiError';
import { SchedulingService } from '../../../services/activityScheduling.service';
import { HostService } from '../../../services/host.service';
import ApiError from '../../../../../common/utils/helper/ApiError';
import { verifyHostToken } from '../../../../../common/middlewares/jwt/authForHost';
import { scheduleActivity } from '../../../../../common/utils/validation/host/createSchedulingOfAct.validation';
import { z } from 'zod';
const schedulingService = new SchedulingService(prismaClient);
const hostService = new HostService(prismaClient);

View File

@@ -90,7 +90,7 @@ export async function sendAMPQQAcceptanceMailtoHost(
<p>Congratulations, Your activity onboarding application to minglar admin has been approved.</p>
<p>You can start adding other details of your activity through the host panel.</p>
<p> You can login to your account using the link below:<br/>
<strong>Link:</strong> ${config.HOST_LINK} </p>
<strong>Link:</strong> ${config.HOST_LINK_PQ} </p>
<p>Best regards,<br/>Minglar Team</p>
`;

View File

@@ -18,7 +18,7 @@ export const handler = safeHandler(async (
}
const userInfo = await verifyUserToken(token);
const userId = Number(userInfo.id);
// const userId = Number(userInfo.id);
const interestId = Number(event.queryStringParameters?.interestId);
const page = Number(event.queryStringParameters?.page ?? 1);
@@ -33,7 +33,6 @@ export const handler = safeHandler(async (
}
const result = await userService.viewMoreActivitiesByInterest(
userId,
interestId,
page,
limit

View File

@@ -0,0 +1,56 @@
import { APIGatewayProxyEvent, APIGatewayProxyResult, Context } from 'aws-lambda';
import { safeHandler } from '../../../../common/utils/handlers/safeHandler';
import { prismaClient } from '../../../../common/database/prisma.lambda.service';
import ApiError from '../../../../common/utils/helper/ApiError';
import { UserService } from '../../services/user.service';
import { verifyUserToken } from '../../../../common/middlewares/jwt/authForUser';
const userService = new UserService(prismaClient);
export const handler = safeHandler(async (
event: APIGatewayProxyEvent,
context?: Context
): Promise<APIGatewayProxyResult> => {
const token = event.headers['x-auth-token'] || event.headers['X-Auth-Token'];
if (!token) {
throw new ApiError(400, 'This is a protected route.');
}
const userInfo = await verifyUserToken(token);
const userId = Number(userInfo.id);
const type = event.queryStringParameters?.type;
const page = Number(event.queryStringParameters?.page ?? 1);
const limit = Number(event.queryStringParameters?.limit ?? 20);
const countryName = event.queryStringParameters?.countryName;
const stateName = event.queryStringParameters?.stateName;
const cityName = event.queryStringParameters?.cityName;
if (!type) {
throw new ApiError(400, 'Type is required');
}
const result = await userService.viewMoreActivities(
userId,
type,
page,
limit,
countryName,
stateName,
cityName
);
return {
statusCode: 200,
headers: {
'Content-Type': 'application/json',
'Access-Control-Allow-Origin': '*',
},
body: JSON.stringify({
success: true,
message: `${type} activities fetched successfully`,
data: result,
}),
};
});

View File

@@ -2473,7 +2473,6 @@ export class UserService {
}
async viewMoreActivitiesByInterest(
userId: number,
interestId: number,
page: number,
limit: number
@@ -2602,6 +2601,140 @@ export class UserService {
});
}
async viewMoreActivities(
userId: number,
type: string,
page: number,
limit: number,
countryName?: string,
stateName?: string,
cityName?: string,
) {
return await this.prisma.$transaction(async (tx) => {
const userAddressDetails = await tx.userAddressDetails.findFirst({
where: { userXid: userId },
select: {
countryXid: true,
stateXid: true,
cityXid: true,
},
});
let effectiveLocation = null;
if (countryName && stateName && cityName) {
effectiveLocation = await findOrCreateLocation(tx, {
countryName,
stateName,
cityName,
});
} else if (userAddressDetails) {
effectiveLocation = userAddressDetails;
}
const effectiveCountryXid = effectiveLocation?.countryXid ?? null;
const effectiveStateXid = effectiveLocation?.stateXid ?? null;
/* =======================================================
SWITCH BASED VIEW MORE TYPE
======================================================= */
switch (type) {
/* ==========================================
1⃣ MOST HYPED
========================================== */
case 'mostHyped': {
const grouped = await tx.userBucketInterested.groupBy({
by: ['activityXid'],
where: {
isActive: true,
isBucket: false,
},
_count: {
activityXid: true,
},
});
const sortedIds = grouped
.sort((a, b) => b._count.activityXid - a._count.activityXid)
.map(g => g.activityXid);
const where = {
id: { in: sortedIds },
isActive: true,
activityInternalStatus: ACTIVITY_INTERNAL_STATUS.ACTIVITY_LISTED,
amInternalStatus: ACTIVITY_AM_INTERNAL_STATUS.ACTIVITY_LISTED,
};
return await rankAndPaginateActivities(tx, where, page, limit);
}
/* ==========================================
2⃣ NEW ARRIVALS
========================================== */
case 'newArrivals': {
const where = {
isActive: true,
activityInternalStatus: ACTIVITY_INTERNAL_STATUS.ACTIVITY_LISTED,
amInternalStatus: ACTIVITY_AM_INTERNAL_STATUS.ACTIVITY_LISTED,
createdAt: {
gte: new Date(Date.now() - 31 * 24 * 60 * 60 * 1000),
},
};
return await rankAndPaginateActivities(tx, where, page, limit);
}
/* ==========================================
3⃣ OTHER STATES
========================================== */
case 'otherStates': {
const where: any = {
isActive: true,
activityInternalStatus: ACTIVITY_INTERNAL_STATUS.ACTIVITY_LISTED,
amInternalStatus: ACTIVITY_AM_INTERNAL_STATUS.ACTIVITY_LISTED,
};
if (effectiveCountryXid) {
where.checkInCountryXid = effectiveCountryXid;
}
if (effectiveStateXid) {
where.checkInStateXid = { not: effectiveStateXid };
}
return await rankAndPaginateActivities(tx, where, page, limit);
}
/* ==========================================
4⃣ OVERSEAS
========================================== */
case 'overSeas': {
const where: any = {
isActive: true,
activityInternalStatus: ACTIVITY_INTERNAL_STATUS.ACTIVITY_LISTED,
amInternalStatus: ACTIVITY_AM_INTERNAL_STATUS.ACTIVITY_LISTED,
};
if (effectiveCountryXid) {
where.checkInCountryXid = { not: effectiveCountryXid };
}
return await rankAndPaginateActivities(tx, where, page, limit);
}
default:
throw new Error('Invalid type');
}
});
}
async getConnectionCountOfUser(userXid: number) {
return await this.prisma.connectDetails.count({
where: {