Skip to content

Commit

Permalink
refactor: Update acceptance rate calculation in MetricsViewer.vue
Browse files Browse the repository at this point in the history
  • Loading branch information
martedesco committed May 31, 2024
1 parent ea11d05 commit fb4e70f
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/components/MetricsViewer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -252,11 +252,9 @@ export default defineComponent({
}
]
};
let sum = 0;
const acceptanceRates = data.map((m: Metrics) => {
const rate = m.total_lines_suggested !== 0 ? (m.total_lines_accepted / m.total_lines_suggested) * 100 : 0;
sum += rate;
return rate;
});
Expand All @@ -274,8 +272,12 @@ export default defineComponent({
}
]
};
acceptanceRateAverage.value = cumulativeNumberAcceptances.value / cumulativeNumberSuggestions.value * 100;
if(cumulativeNumberSuggestions.value === 0){
acceptanceRateAverage.value = 0;
} else {
acceptanceRateAverage.value = cumulativeNumberAcceptances.value / cumulativeNumberSuggestions.value * 100;
}
totalActiveUsersChartData.value = {
labels: data.map((m: Metrics) => m.day),
Expand Down

0 comments on commit fb4e70f

Please sign in to comment.