sending the 5 random users profile image in the getbyid api

This commit is contained in:
2026-02-28 13:36:33 +05:30
parent fe6bb59cc7
commit cc2fa3eb6b

View File

@@ -2059,13 +2059,6 @@ export class UserService {
const connectionUserIds = connectionUsers.map((u) => u.userXid);
const interestedCount = await tx.userBucketInterested.count({
where: {
activityXid,
isBucket: false,
isActive: true,
},
});
const connectionInterestedCount = connectionUserIds.length
? await tx.userBucketInterested.count({
@@ -2087,6 +2080,50 @@ export class UserService {
(v) => v.venueCapacity ?? 0,
).reduce((sum, capacity) => sum + capacity, 0);
const interestedCount = await tx.userBucketInterested.count({
where: {
activityXid,
isBucket: false,
isActive: true,
},
});
const interestedUsers = await tx.userBucketInterested.findMany({
where: {
activityXid,
isBucket: false,
isActive: true,
user: {
isActive: true,
},
},
select: {
user: {
select: {
profileImage: true,
},
},
},
});
const shuffledUsers = interestedUsers.sort(() => 0.5 - Math.random());
const randomFive = shuffledUsers.slice(0, 5);
const interestedUserImages: string[] = [];
for (const item of randomFive) {
const profileImage = item.user.profileImage;
if (profileImage) {
const key = profileImage.startsWith('http')
? new URL(profileImage).pathname.replace(/^\/+/, '')
: profileImage;
const presignedUrl = await getPresignedUrl(bucket, key);
interestedUserImages.push(presignedUrl);
}
}
return {
activity,
interestedCount,
@@ -2095,6 +2132,7 @@ export class UserService {
totalCapacity,
rating: 0, // ⭐ Placeholder, implement rating logic as needed
distance: 0,
interestedUserImages
};
});
}