sending the lowest price for activity and sending the venue prices

This commit is contained in:
2026-04-10 17:55:16 +05:30
parent 0f5061a129
commit daff265584

View File

@@ -2243,6 +2243,24 @@ export class ItineraryService {
venueName: true, venueName: true,
venueLabel: true, venueLabel: true,
venueCapacity: true, venueCapacity: true,
ActivityPrices: {
where: {
isActive: true,
deletedAt: null,
},
orderBy: {
createdAt: 'asc',
},
select: {
id: true,
noOfSession: true,
isPackage: true,
sessionValidity: true,
sessionValidityFrequency: true,
basePrice: true,
sellPrice: true,
},
},
ActivityVenueArtifacts: { ActivityVenueArtifacts: {
where: { where: {
isActive: true, isActive: true,
@@ -2419,6 +2437,7 @@ export class ItineraryService {
venueXid: venue.id, venueXid: venue.id,
venueName: venue.venueName, venueName: venue.venueName,
venueLabel: venue.venueLabel, venueLabel: venue.venueLabel,
activityPrices: venue.ActivityPrices,
mediaFileName: venue.ActivityVenueArtifacts[0]?.mediaFileName ?? null, mediaFileName: venue.ActivityVenueArtifacts[0]?.mediaFileName ?? null,
mediaType: venue.ActivityVenueArtifacts[0]?.mediaType ?? null, mediaType: venue.ActivityVenueArtifacts[0]?.mediaType ?? null,
venueCapacity: venue.venueCapacity, venueCapacity: venue.venueCapacity,
@@ -2466,12 +2485,64 @@ export class ItineraryService {
new Date(second!.startDateTime).getTime(), new Date(second!.startDateTime).getTime(),
); );
const venuePriceDetails = activity.ActivityVenues.map((venue) => {
const prices = venue.ActivityPrices.map((price) => ({
id: price.id,
noOfSession: price.noOfSession,
isPackage: price.isPackage,
sessionValidity: price.sessionValidity,
sessionValidityFrequency: price.sessionValidityFrequency,
basePrice: price.basePrice,
sellPrice: price.sellPrice,
}));
const lowestPrice = venue.ActivityPrices.reduce(
(lowest, current) =>
!lowest || current.sellPrice < lowest.sellPrice ? current : lowest,
null as (typeof venue.ActivityPrices)[number] | null,
);
return {
venueXid: venue.id,
venueName: venue.venueName,
venueLabel: venue.venueLabel,
venueCapacity: venue.venueCapacity,
availableSeats: venue.availableSeats,
activityPrice: lowestPrice?.sellPrice ?? null,
activityBasePrice: lowestPrice?.basePrice ?? null,
activityPriceDetails: lowestPrice,
prices,
};
});
const lowestPriceVenue = venuePriceDetails.reduce(
(lowest, current) => {
if (!lowest) {
return current;
}
if (lowest.activityPrice === null) {
return current;
}
if (current.activityPrice === null) {
return lowest;
}
return current.activityPrice < lowest.activityPrice ? current : lowest;
},
null as (typeof venuePriceDetails)[number] | null,
);
const coverImage = const coverImage =
activity.ActivitiesMedia.find((media) => media.isCoverImage) ?? activity.ActivitiesMedia.find((media) => media.isCoverImage) ??
activity.ActivitiesMedia[0] ?? activity.ActivitiesMedia[0] ??
null; null;
const energyLevel = activity.activityType?.energyLevel ?? null; const energyLevel = activity.activityType?.energyLevel ?? null;
const lowestActivityPrice = lowestPriceVenue?.activityPrice ?? null;
const lowestActivityBasePrice = lowestPriceVenue?.activityBasePrice ?? null;
const lowestActivityPriceDetails = lowestPriceVenue?.activityPriceDetails ?? null;
return { return {
userBucketInterestedXid: entry.id, userBucketInterestedXid: entry.id,
@@ -2479,6 +2550,12 @@ export class ItineraryService {
isBucket: entry.isBucket, isBucket: entry.isBucket,
bucketTypeName: entry.bucketTypeName, bucketTypeName: entry.bucketTypeName,
distance, distance,
activityPrice: lowestActivityPrice,
activityBasePrice: lowestActivityBasePrice,
activityPriceDetails: lowestActivityPriceDetails,
lowestActivityPrice,
lowestActivityBasePrice,
lowestActivityPriceDetails,
activityTitle: activity.activityTitle, activityTitle: activity.activityTitle,
activityDescription: activity.activityDescription, activityDescription: activity.activityDescription,
activityDurationMins, activityDurationMins,
@@ -2486,13 +2563,19 @@ export class ItineraryService {
activityCoverImagePresignedUrl: await attachPresignedUrl( activityCoverImagePresignedUrl: await attachPresignedUrl(
coverImage?.mediaFileName, coverImage?.mediaFileName,
), ),
venue: availableSlotsWithPresignedUrl[0] venue: lowestPriceVenue
? { ? {
venueXid: availableSlotsWithPresignedUrl[0].venueXid, venueXid: lowestPriceVenue.venueXid,
venueName: availableSlotsWithPresignedUrl[0].venueName, venueName: lowestPriceVenue.venueName,
venueLabel: availableSlotsWithPresignedUrl[0].venueLabel, venueLabel: lowestPriceVenue.venueLabel,
venueCapacity: lowestPriceVenue.venueCapacity,
availableSeats: lowestPriceVenue.availableSeats,
activityPrice: lowestPriceVenue.activityPrice,
activityBasePrice: lowestPriceVenue.activityBasePrice,
activityPriceDetails: lowestPriceVenue.activityPriceDetails,
} }
: null, : null,
venuePrices: venuePriceDetails,
availableSlots: availableSlotsWithPresignedUrl, availableSlots: availableSlotsWithPresignedUrl,
entryType: activity.ActivityAllowedEntry[0]?.allowedEntryType ?? null, entryType: activity.ActivityAllowedEntry[0]?.allowedEntryType ?? null,
energyLevel: energyLevel energyLevel: energyLevel
@@ -2641,6 +2724,7 @@ export class ItineraryService {
hasPreviousPage: sanitizedPage > 1 && totalPages > 0, hasPreviousPage: sanitizedPage > 1 && totalPages > 0,
}, },
count: paginatedActivities.length, count: paginatedActivities.length,
activityCount: totalCount,
totalCount, totalCount,
activities: paginatedActivities, activities: paginatedActivities,
}; };