Skip to content

Commit ed58163

Browse files
committed
Fix division by zero errors and update max values for user metrics in TargetValuesService
1 parent bfb13cd commit ed58163

1 file changed

Lines changed: 13 additions & 13 deletions

File tree

backend/src/services/target.service.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ class TargetValuesService {
6767
};
6868
}, { totalSeats: 0, totalActive: 0, totalInactive: 0 });
6969

70-
const avgTotalSeats = Math.round(averages.totalSeats / topAdoptions.length);
71-
const avgTotalActive = Math.round(averages.totalActive / topAdoptions.length);
70+
const avgTotalSeats = Math.round(averages.totalSeats / topAdoptions.length) || 0;
71+
const avgTotalActive = Math.round(averages.totalActive / topAdoptions.length) || 0;
7272

7373
return {
7474
org: {
@@ -77,24 +77,24 @@ class TargetValuesService {
7777
monthlyDevsReportingTimeSavings: { current: 0, target: 0, max: avgTotalSeats },
7878
percentOfSeatsReportingTimeSavings: { current: 0, target: 0, max: 100 },
7979
percentOfSeatsAdopted: {
80-
current: Math.round((avgTotalActive / avgTotalSeats) * 100),
81-
target: Math.round((avgTotalActive / avgTotalSeats) * 100),
80+
current: avgTotalActive ? Math.round((avgTotalActive / avgTotalSeats) * 100) : 0,
81+
target: avgTotalSeats ? Math.round((avgTotalActive / avgTotalSeats) * 100) : 0,
8282
max: 100
8383
},
8484
percentOfMaxAdopted: { current: 0, target: 0, max: 100 },
8585
},
8686
user: {
87-
dailySuggestions: { current: 0, target: 0, max: 0 },
88-
dailyAcceptances: { current: 0, target: 0, max: 0 },
89-
dailyChatTurns: { current: 0, target: 0, max: 0 },
90-
dailyDotComChats: { current: 0, target: 0, max: 0 },
91-
weeklyPRSummaries: { current: 0, target: 0, max: 0 },
92-
weeklyTimeSavedHrs: { current: 0, target: 0, max: 0 },
87+
dailySuggestions: { current: 0, target: 0, max: 100 },
88+
dailyAcceptances: { current: 0, target: 0, max: 100 },
89+
dailyChatTurns: { current: 0, target: 0, max: 100 },
90+
dailyDotComChats: { current: 0, target: 0, max: 100 },
91+
weeklyPRSummaries: { current: 0, target: 0, max: 100 },
92+
weeklyTimeSavedHrs: { current: 0, target: 0, max: 100 },
9393
},
9494
impact: {
95-
monthlyTimeSavingsHrs: { current: 0, target: 0, max: 0 },
96-
annualTimeSavingsAsDollars: { current: 0, target: 0, max: 0 },
97-
productivityOrThroughputBoostPercent: { current: 0, target: 0, max: 100 },
95+
monthlyTimeSavingsHrs: { current: 0, target: 0, max: 80 * avgTotalSeats },
96+
annualTimeSavingsAsDollars: { current: 0, target: 0, max: 80 * avgTotalSeats * 50 },
97+
productivityOrThroughputBoostPercent: { current: 0, target: 0, max: 25 },
9898
},
9999
};
100100
}

0 commit comments

Comments
 (0)