Issue Description
An ArithmeticException is occurring in the ClinicActivityDataService when calculating active logs ratio due to a division by zero scenario.
Impact
- Service failures when attempting to calculate ratios for log types with no entries
- Affects endpoints:
- /api/clinic-activity/active-errors-ratio
- /api/clinic-activity/active-warning-ratio
Root Cause
The getActiveLogsRatio method performs division without checking for a zero denominator:
public int getActiveLogsRatio(String type) {
var all = repository.countLogsByType(type);
var active = repository.countActiveLogsByType(type);
return active/all; // Throws ArithmeticException when all == 0
}
Solution
A fix has been implemented in PR #99 that:
- Adds validation for zero denominator
- Returns 0 when no logs exist
- Adds proper error logging
- Converts ratio to percentage for better readability
Additional Notes
- Added warning logs to help track when this edge case occurs
- Improved method to return percentage instead of raw ratio for better usability
Related PR: #99
Issue Description
An ArithmeticException is occurring in the ClinicActivityDataService when calculating active logs ratio due to a division by zero scenario.
Impact
Root Cause
The
getActiveLogsRatiomethod performs division without checking for a zero denominator:Solution
A fix has been implemented in PR #99 that:
Additional Notes
Related PR: #99