Skip to content

Commit

Permalink
refactor: Initialize countPositive with a default value of 0 in Analy…
Browse files Browse the repository at this point in the history
…ticsDatabaseService

This commit modifies the AnalyticsDatabaseService by initializing the countPositive variable with a default value of 0 when the strResult is null or undefined. This change ensures that countPositive is always assigned a value, even when there is no valid strResult.

The modification improves the reliability of the countPositive variable and prevents potential errors when using it in subsequent calculations.

Co-authored-by: [Author Name]
  • Loading branch information
simlarsen committed Jul 25, 2024
1 parent 3c92849 commit 2c7b845
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion CommonServer/Services/AnalyticsDatabaseService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ export default class AnalyticsDatabaseService<
dbResult.stream,
);

let countPositive: PositiveNumber = new PositiveNumber(strResult);
let countPositive: PositiveNumber = new PositiveNumber(strResult || 0);

if (countBy.groupBy && Object.keys(countBy.groupBy).length > 0) {
// this usually happens when group by is used. In this case we count the total number of groups and not rows in those groups.
Expand Down

0 comments on commit 2c7b845

Please sign in to comment.