fixed the response structure in the specific api
This commit is contained in:
@@ -145,7 +145,10 @@ export class FilteredLandingPageService {
|
||||
Math.sin(dLon / 2);
|
||||
|
||||
const c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
|
||||
return R * c;
|
||||
const distance = R * c;
|
||||
|
||||
// return distance rounded to 2 decimals
|
||||
return Number(distance.toFixed(2));
|
||||
};
|
||||
|
||||
async rankAndPaginateActivities(
|
||||
@@ -560,26 +563,32 @@ export class FilteredLandingPageService {
|
||||
);
|
||||
|
||||
// Group by interests for the final structure
|
||||
const interestsWithActivityTypes = await Promise.all(Object.values(activityTypesByInterest).map(
|
||||
async (interestGroup: any) => ({
|
||||
interestId: interestGroup.interest.id,
|
||||
interestName: interestGroup.interest.interestName,
|
||||
interestColor: interestGroup.interest.interestColor,
|
||||
interestImage: interestGroup.interest.interestImage,
|
||||
interestImagePresignedUrl: await attachPresignedUrl(interestGroup.interest.interestImage),
|
||||
displayOrder: interestGroup.interest.displayOrder,
|
||||
activityTypes: interestGroup.activityTypes.map((at: any) => {
|
||||
const activityTypeData = activitiesByActivityType.find(
|
||||
(adata) => adata.activityTypeId === at.activityTypeId
|
||||
);
|
||||
return {
|
||||
...at,
|
||||
activities: activityTypeData?.activities || [],
|
||||
pagination: activityTypeData?.pagination || { page, limit, hasMore: false },
|
||||
};
|
||||
}),
|
||||
}),
|
||||
));
|
||||
const interestsWithActivities = await Promise.all(
|
||||
Object.values(activityTypesByInterest).map(async (interestGroup: any) => {
|
||||
|
||||
// collect all activities belonging to this interest
|
||||
const activitiesForInterest = activitiesByActivityType
|
||||
.filter(a => a.interestXid === interestGroup.interest.id)
|
||||
.flatMap(a => a.activities);
|
||||
|
||||
return {
|
||||
interestId: interestGroup.interest.id,
|
||||
interestName: interestGroup.interest.interestName,
|
||||
interestColor: interestGroup.interest.interestColor,
|
||||
interestImage: interestGroup.interest.interestImage,
|
||||
interestImagePresignedUrl: await attachPresignedUrl(
|
||||
interestGroup.interest.interestImage
|
||||
),
|
||||
displayOrder: interestGroup.interest.displayOrder,
|
||||
|
||||
page,
|
||||
limit,
|
||||
hasMore: activitiesForInterest.length === limit,
|
||||
|
||||
activities: activitiesForInterest
|
||||
};
|
||||
})
|
||||
);
|
||||
|
||||
// Most Hyped Activities with filtering
|
||||
const mostHypedGrouped = await tx.userBucketInterested.groupBy({
|
||||
@@ -916,8 +925,7 @@ export class FilteredLandingPageService {
|
||||
limit,
|
||||
},
|
||||
randomActivities,
|
||||
interests: interestsWithActivityTypes,
|
||||
activityTypes: activitiesByActivityType,
|
||||
interests: interestsWithActivities,
|
||||
otherStatesActivities: formattedOtherStatesActivities,
|
||||
overSeasActivities: formattedOverSeasActivities,
|
||||
newArrivalsActivities: formattedNewArrivalsActivities,
|
||||
|
||||
Reference in New Issue
Block a user