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