Skip to content

Commit

Permalink
Remove recommanded section
Browse files Browse the repository at this point in the history
  • Loading branch information
cp-sumi-k committed Feb 12, 2024
1 parent 2fb0cac commit bce2d1e
Showing 1 changed file with 2 additions and 31 deletions.
33 changes: 2 additions & 31 deletions admin/src/api/post/controllers/post.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,43 +28,14 @@ module.exports = createCoreController("api::post.post", ({ strapi }) => ({
},
},
},
});

const recommandedPosts = await strapi.db.query("api::post.post").findMany({
select: ['title','published_on','tags','content','slug'],
where: {
$and: [
{
slug: { $ne: entity.slug },
},
{
is_resource: entity.is_resource,
},
],
},
sort: { published_on: "desc" },
populate: {
image:true,
author: {
populate: {
image: true,
},
},
},
});

entity.recommandedPosts = recommandedPosts
.filter((post) => {
return entity.tags
.map((t) => t.name)
.some((r) => post.tags.map((t) => t.name).includes(r));
})

return this.transformResponse(entity);
},

async find(ctx) {
let posts = await strapi.entityService.findMany("api::post.post", {
filters: { is_resource: ctx.query.filters.is_resource },
publicationState: ctx.query.publicationState,
sort: { published_on: "desc" },
populate: {
Expand Down Expand Up @@ -104,4 +75,4 @@ module.exports = createCoreController("api::post.post", ({ strapi }) => ({

return this.transformResponse(posts);
},
}));
}));

0 comments on commit bce2d1e

Please sign in to comment.