diff --git a/src/modules/user/services/user.service.ts b/src/modules/user/services/user.service.ts index 41e014b..4f28bee 100644 --- a/src/modules/user/services/user.service.ts +++ b/src/modules/user/services/user.service.ts @@ -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 }; }); }