Skip to content

Commit

Permalink
COM-939 fix from pr comments
Browse files Browse the repository at this point in the history
  • Loading branch information
cmolle committed Jan 17, 2020
1 parent 286daea commit 8706732
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
6 changes: 3 additions & 3 deletions src/api/Stats.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
Expand Down
18 changes: 8 additions & 10 deletions src/pages/ni/auxiliaries/Dashboard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
}
}
Expand Down

0 comments on commit 8706732

Please sign in to comment.