[AB-84] fixing incorrect calculation for agreement percentage

This commit is contained in:
Sheldan
2023-02-25 18:33:02 +01:00
parent f091559c49
commit 97895f5c56

View File

@@ -279,8 +279,12 @@ public class SuggestionServiceBean implements SuggestionService {
Long disagreements = suggestionVoteManagementService.getDecisionsForSuggestion(suggestion, SuggestionDecision.DISAGREE);
Long suggestionId = suggestion.getSuggestionId().getId();
Long totalVotes = disagreements + agreements;
float agreementPercentage = (float) agreements / (totalVotes) * 100;
float disAgreementPercentage = 100f - agreementPercentage;
float agreementPercentage = 0;
float disAgreementPercentage = 0;
if(totalVotes > 0) {
agreementPercentage = (((float) agreements) / totalVotes) * 100;
disAgreementPercentage = 100f - agreementPercentage;
}
SuggestionUpdateModel model = SuggestionUpdateModel
.builder()
.suggestionId(suggestionId)