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