From c0bce488afae6cab1673a97be0dfa02c3ef04617 Mon Sep 17 00:00:00 2001 From: cp-sumi-k Date: Tue, 20 Feb 2024 13:22:22 +0530 Subject: [PATCH] Fix: post count query --- admin/src/api/post/content-types/post/lifecycles.js | 7 +++++-- admin/src/api/post/controllers/post.js | 7 ++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/admin/src/api/post/content-types/post/lifecycles.js b/admin/src/api/post/content-types/post/lifecycles.js index e7d4cc1..df1bb22 100644 --- a/admin/src/api/post/content-types/post/lifecycles.js +++ b/admin/src/api/post/content-types/post/lifecycles.js @@ -56,7 +56,6 @@ module.exports = { }; await strapi.plugins["email"].services.email.send(emailData); } - } } }, @@ -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 + ); + } } } diff --git a/admin/src/api/post/controllers/post.js b/admin/src/api/post/controllers/post.js index 28d9700..1cc86ec 100644 --- a/admin/src/api/post/controllers/post.js +++ b/admin/src/api/post/controllers/post.js @@ -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,