taking array of schoolCompanyXids
This commit is contained in:
@@ -25,20 +25,29 @@ export const handler = safeHandler(async (
|
|||||||
throw new ApiError(400, 'Invalid user');
|
throw new ApiError(400, 'Invalid user');
|
||||||
}
|
}
|
||||||
|
|
||||||
const schoolCompanyXid = Number(event.queryStringParameters?.schoolCompanyXid);
|
|
||||||
const page = Number(event.queryStringParameters?.page ?? 1);
|
const page = Number(event.queryStringParameters?.page ?? 1);
|
||||||
const limit = Number(event.queryStringParameters?.limit ?? 20);
|
const limit = Number(event.queryStringParameters?.limit ?? 20);
|
||||||
const countryName = event.queryStringParameters?.countryName ?? '';
|
const countryName = event.queryStringParameters?.countryName ?? '';
|
||||||
const stateName = event.queryStringParameters?.stateName ?? '';
|
const stateName = event.queryStringParameters?.stateName ?? '';
|
||||||
const cityName = event.queryStringParameters?.cityName ?? '';
|
const cityName = event.queryStringParameters?.cityName ?? '';
|
||||||
|
const schoolCompanyXidsParam = event.queryStringParameters?.schoolCompanyXids;
|
||||||
|
|
||||||
if (!schoolCompanyXid) {
|
if (!schoolCompanyXidsParam) {
|
||||||
throw new ApiError(400, 'schoolCompanyXid is required');
|
throw new ApiError(400, 'schoolCompanyXids is required');
|
||||||
|
}
|
||||||
|
|
||||||
|
const schoolCompanyXids = schoolCompanyXidsParam
|
||||||
|
.split(',')
|
||||||
|
.map(id => Number(id))
|
||||||
|
.filter(id => !isNaN(id));
|
||||||
|
|
||||||
|
if (!schoolCompanyXids.length) {
|
||||||
|
throw new ApiError(400, 'Invalid schoolCompanyXids');
|
||||||
}
|
}
|
||||||
|
|
||||||
const result = await userService.getAllActivitiesFromConnectionsUserInterests(
|
const result = await userService.getAllActivitiesFromConnectionsUserInterests(
|
||||||
userId,
|
userId,
|
||||||
schoolCompanyXid,
|
schoolCompanyXids,
|
||||||
page,
|
page,
|
||||||
limit,
|
limit,
|
||||||
countryName,
|
countryName,
|
||||||
|
|||||||
@@ -1997,7 +1997,7 @@ export class UserService {
|
|||||||
|
|
||||||
async getAllActivitiesFromConnectionsUserInterests(
|
async getAllActivitiesFromConnectionsUserInterests(
|
||||||
userId: number,
|
userId: number,
|
||||||
schoolCompanyXid: number,
|
schoolCompanyXids: number[],
|
||||||
page: number,
|
page: number,
|
||||||
limit: number,
|
limit: number,
|
||||||
countryName: string,
|
countryName: string,
|
||||||
@@ -2010,7 +2010,7 @@ export class UserService {
|
|||||||
where: {
|
where: {
|
||||||
isActive: true,
|
isActive: true,
|
||||||
schoolCompanyXid: {
|
schoolCompanyXid: {
|
||||||
in: [schoolCompanyXid],
|
in: schoolCompanyXids,
|
||||||
},
|
},
|
||||||
userXid: {
|
userXid: {
|
||||||
not: userId,
|
not: userId,
|
||||||
@@ -2031,9 +2031,11 @@ export class UserService {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const networkUserIds = [...new Set(networkUsers.map(u => u.userXid))];
|
||||||
|
|
||||||
const networkUserInterests = await tx.userInterests.findMany({
|
const networkUserInterests = await tx.userInterests.findMany({
|
||||||
where: {
|
where: {
|
||||||
userXid: { in: networkUsers.map(u => u.userXid) },
|
userXid: { in: networkUserIds },
|
||||||
isActive: true,
|
isActive: true,
|
||||||
},
|
},
|
||||||
distinct: ['interestXid'],
|
distinct: ['interestXid'],
|
||||||
@@ -2346,7 +2348,7 @@ export class UserService {
|
|||||||
isActive: true,
|
isActive: true,
|
||||||
activityInternalStatus: ACTIVITY_INTERNAL_STATUS.ACTIVITY_LISTED,
|
activityInternalStatus: ACTIVITY_INTERNAL_STATUS.ACTIVITY_LISTED,
|
||||||
amInternalStatus: ACTIVITY_AM_INTERNAL_STATUS.ACTIVITY_LISTED,
|
amInternalStatus: ACTIVITY_AM_INTERNAL_STATUS.ACTIVITY_LISTED,
|
||||||
activityTypeXid: { in: activityTypes.map(a => a.id) },
|
activityTypeXid: { in: activityTypeIds },
|
||||||
};
|
};
|
||||||
|
|
||||||
if (effectiveCountryXid) {
|
if (effectiveCountryXid) {
|
||||||
@@ -2366,7 +2368,7 @@ export class UserService {
|
|||||||
isActive: true,
|
isActive: true,
|
||||||
activityInternalStatus: ACTIVITY_INTERNAL_STATUS.ACTIVITY_LISTED,
|
activityInternalStatus: ACTIVITY_INTERNAL_STATUS.ACTIVITY_LISTED,
|
||||||
amInternalStatus: ACTIVITY_AM_INTERNAL_STATUS.ACTIVITY_LISTED,
|
amInternalStatus: ACTIVITY_AM_INTERNAL_STATUS.ACTIVITY_LISTED,
|
||||||
activityTypeXid: { in: activityTypes.map(a => a.id) },
|
activityTypeXid: { in: activityTypeIds },
|
||||||
};
|
};
|
||||||
|
|
||||||
if (effectiveCountryXid) {
|
if (effectiveCountryXid) {
|
||||||
|
|||||||
Reference in New Issue
Block a user