fix: division by zero in language stats (#2171)
* fix: division by zero in language stats Signed-off-by: Jos Ahrens <jahrens@digitalocean.com> * Modify minor to patch version in changeset Co-authored-by: Vincenzo Scamporlino <vincenzos@spotify.com> Signed-off-by: Jos Ahrens <github@liefland.net> --------- Signed-off-by: Jos Ahrens <jahrens@digitalocean.com> Signed-off-by: Jos Ahrens <github@liefland.net> Co-authored-by: Vincenzo Scamporlino <vincenzos@spotify.com>
This commit is contained in:
parent
10226f119f
commit
46c48374cb
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
'@backstage-community/plugin-copilot': patch
|
||||
---
|
||||
|
||||
Fix division by zero in language stats
|
||||
|
|
@ -45,14 +45,19 @@ export function getLanguageStats(metricsArray: Metric[]): LanguageStats[] {
|
|||
if (existingStats) {
|
||||
existingStats.totalSuggestions += item.suggestions_count;
|
||||
existingStats.totalAcceptances += item.acceptances_count;
|
||||
existingStats.acceptanceRate =
|
||||
existingStats.totalAcceptances / existingStats.totalSuggestions;
|
||||
if (existingStats.totalSuggestions > 0) {
|
||||
existingStats.acceptanceRate =
|
||||
existingStats.totalAcceptances / existingStats.totalSuggestions;
|
||||
}
|
||||
} else {
|
||||
languageStatsMap.set(item.language, {
|
||||
language: item.language,
|
||||
totalSuggestions: item.suggestions_count,
|
||||
totalAcceptances: item.acceptances_count,
|
||||
acceptanceRate: item.acceptances_count / item.suggestions_count,
|
||||
acceptanceRate:
|
||||
item.suggestions_count > 0
|
||||
? item.acceptances_count / item.suggestions_count
|
||||
: 0,
|
||||
});
|
||||
}
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in New Issue