Skip to content

Commit

Permalink
Merge pull request #149 from canopas/fix-count-query
Browse files Browse the repository at this point in the history
Fix: post count query
  • Loading branch information
cp-sumi-k committed Feb 20, 2024
2 parents 3427529 + c0bce48 commit 3426b18
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
7 changes: 5 additions & 2 deletions admin/src/api/post/content-types/post/lifecycles.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ module.exports = {
};
await strapi.plugins["email"].services.email.send(emailData);
}

}
}
},
Expand All @@ -78,7 +77,11 @@ async function modifyContentAndSetErrorMsg(event) {
await generateTOC(result, event);
await generateNewToc(result, event);
await generatePreview(event);
event.params.data.reading_time = getReadingTime(event.params.data.content);
if (event.params.data.content) {
event.params.data.reading_time = getReadingTime(
event.params.data.content
);
}
}
}

Expand Down
7 changes: 4 additions & 3 deletions admin/src/api/post/controllers/post.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,10 @@ module.exports = createCoreController("api::post.post", ({ strapi }) => ({
},

async find(ctx) {
const count = await strapi
.query("api::post.post")
.count({ where: { is_resource: ctx.query.filters.is_resource } });
const count = await strapi.entityService.count("api::post.post", {
filters: ctx.query.filters,
publicationState: ctx.query.publicationState,
});

const posts = await strapi.entityService.findMany("api::post.post", {
filters: ctx.query.filters,
Expand Down

0 comments on commit 3426b18

Please sign in to comment.