mirror of
https://github.com/Sheldan/abstracto.git
synced 2026-04-15 04:02:53 +00:00
[AB-84] fixing incorrect calculation for agreement percentage
This commit is contained in:
@@ -279,8 +279,12 @@ public class SuggestionServiceBean implements SuggestionService {
|
|||||||
Long disagreements = suggestionVoteManagementService.getDecisionsForSuggestion(suggestion, SuggestionDecision.DISAGREE);
|
Long disagreements = suggestionVoteManagementService.getDecisionsForSuggestion(suggestion, SuggestionDecision.DISAGREE);
|
||||||
Long suggestionId = suggestion.getSuggestionId().getId();
|
Long suggestionId = suggestion.getSuggestionId().getId();
|
||||||
Long totalVotes = disagreements + agreements;
|
Long totalVotes = disagreements + agreements;
|
||||||
float agreementPercentage = (float) agreements / (totalVotes) * 100;
|
float agreementPercentage = 0;
|
||||||
float disAgreementPercentage = 100f - agreementPercentage;
|
float disAgreementPercentage = 0;
|
||||||
|
if(totalVotes > 0) {
|
||||||
|
agreementPercentage = (((float) agreements) / totalVotes) * 100;
|
||||||
|
disAgreementPercentage = 100f - agreementPercentage;
|
||||||
|
}
|
||||||
SuggestionUpdateModel model = SuggestionUpdateModel
|
SuggestionUpdateModel model = SuggestionUpdateModel
|
||||||
.builder()
|
.builder()
|
||||||
.suggestionId(suggestionId)
|
.suggestionId(suggestionId)
|
||||||
|
|||||||
Reference in New Issue
Block a user