From 2c9f3f2891ab925a0ad60978133f9ae2db82822c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20FAMIBELLE-PRONZOLA?= Date: Mon, 23 May 2022 00:11:51 +0400 Subject: [PATCH] One call to get stats --- src/api/artiste/controllers/artiste.js | 6 +++--- .../artiste/routes/{count-artiste.js => stats.js} | 2 +- src/api/parole/routes/count-paroles.js | 12 ------------ 3 files changed, 4 insertions(+), 16 deletions(-) rename src/api/artiste/routes/{count-artiste.js => stats.js} (83%) delete mode 100644 src/api/parole/routes/count-paroles.js diff --git a/src/api/artiste/controllers/artiste.js b/src/api/artiste/controllers/artiste.js index a082820..72b5f55 100644 --- a/src/api/artiste/controllers/artiste.js +++ b/src/api/artiste/controllers/artiste.js @@ -10,9 +10,9 @@ const getSlug = text => { module.exports = createCoreController('api::artiste.artiste', ({strapi}) => ({ async count(ctx) { - const {query} = ctx.request - const result = await strapi.entityService.count('api::artiste.artiste', query) - return result + const countArtiste = await strapi.entityService.count('api::artiste.artiste') + const countParole = await strapi.entityService.count('api::parole.parole') + return {countArtiste, countParole} }, async create(ctx) { const {body} = ctx.request diff --git a/src/api/artiste/routes/count-artiste.js b/src/api/artiste/routes/stats.js similarity index 83% rename from src/api/artiste/routes/count-artiste.js rename to src/api/artiste/routes/stats.js index dc6662e..5b4c777 100644 --- a/src/api/artiste/routes/count-artiste.js +++ b/src/api/artiste/routes/stats.js @@ -2,7 +2,7 @@ module.exports = { routes: [ { method: 'GET', - path: '/artiste/count', + path: '/stats', handler: 'artiste.count', config: { auth: false, diff --git a/src/api/parole/routes/count-paroles.js b/src/api/parole/routes/count-paroles.js deleted file mode 100644 index 4652193..0000000 --- a/src/api/parole/routes/count-paroles.js +++ /dev/null @@ -1,12 +0,0 @@ -module.exports = { - routes: [ - { - method: 'GET', - path: '/parole/count', - handler: 'parole.count', - config: { - auth: false, - } - } - ] -}