diff --git a/src/api/Stats.js b/src/api/Stats.js index 13be94b0e9..987814d2ff 100644 --- a/src/api/Stats.js +++ b/src/api/Stats.js @@ -16,9 +16,9 @@ export default { return stats.data.data.allCustomersFundingsMonitoring; }, - async getCustomersAndDurationByAuxiliary (params = null) { - const stats = await alenviAxios.get(`${process.env.API_HOSTNAME}/stats/customer-duration/auxiliary`, { params }); - return stats.data.data.customersAndDuration; + async getPaidInterventionStats (params = null) { + const stats = await alenviAxios.get(`${process.env.API_HOSTNAME}/stats/paid-intervention-stats`, { params }); + return stats.data.data.paidInterventionStats; }, async getCustomersAndDurationBySector (params = null) { const stats = await alenviAxios.get(`${process.env.API_HOSTNAME}/stats/customer-duration/sector`, { params }); diff --git a/src/pages/ni/auxiliaries/Dashboard.vue b/src/pages/ni/auxiliaries/Dashboard.vue index d3828caeac..f25577c45d 100644 --- a/src/pages/ni/auxiliaries/Dashboard.vue +++ b/src/pages/ni/auxiliaries/Dashboard.vue @@ -179,18 +179,16 @@ export default { paidInterventionStats[sector] = []; } if (!sectors.length) return; - const paidInterventionStatsByAuxiliary = await this.$stats.getPaidInterventionStats({ sector: sectors, month: this.selectedMonth }); - for (const paidInterventionStatsForOneSector of paidInterventionStatsByAuxiliary) { - const auxiliarySectors = paidInterventionStatsForOneSector.sectors.reduce((acc, auxiliarySectorsArray) => { - for (const auxiliarySector of auxiliarySectorsArray) { - if (!acc.includes(auxiliarySector)) acc.push(auxiliarySector); - } - return acc; - }, []); - for (const sector of auxiliarySectors) { + const paidInterventionStatsByAuxiliary = await this.$stats.getPaidInterventionStats({ + sector: sectors, + month: this.selectedMonth, + }); + + for (const auxiliaryPaidInterventions of paidInterventionStatsByAuxiliary) { + for (const sector of auxiliaryPaidInterventions.sectors) { if (!sectors.includes(sector)) continue; - paidInterventionStats[sector].push(this.$_.omit(paidInterventionStatsForOneSector, 'sectors')); + paidInterventionStats[sector].push(this.$_.omit(auxiliaryPaidInterventions, 'sectors')); this.$set(this.paidInterventionStats, sector, paidInterventionStats[sector]); } }