[AB-84] adding necessary information to suggestion update message

This commit is contained in:
Sheldan
2023-02-25 18:19:01 +01:00
parent fa7730975e
commit f091559c49
2 changed files with 9 additions and 0 deletions

View File

@@ -278,6 +278,9 @@ public class SuggestionServiceBean implements SuggestionService {
Long agreements = suggestionVoteManagementService.getDecisionsForSuggestion(suggestion, SuggestionDecision.AGREE);
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;
SuggestionUpdateModel model = SuggestionUpdateModel
.builder()
.suggestionId(suggestionId)
@@ -290,6 +293,9 @@ public class SuggestionServiceBean implements SuggestionService {
.text(suggestion.getSuggestionText())
.originalChannelId(channelId)
.reason(reason)
.totalVotes(totalVotes)
.agreementPercentage(agreementPercentage)
.disAgreementPercentage(disAgreementPercentage)
.build();
log.info("Updated posted suggestion {} in server {}.", suggestionId, suggestion.getServer().getId());
CompletableFuture<User> memberById = userService.retrieveUserForId(suggestion.getSuggester().getUserReference().getId());

View File

@@ -25,6 +25,9 @@ public class SuggestionUpdateModel {
private Long originalMessageId;
private Long agreeVotes;
private Long disAgreeVotes;
private Long totalVotes;
private Float agreementPercentage;
private Float disAgreementPercentage;
public String getOriginalMessageUrl() {
return MessageUtils.buildMessageUrl(serverId, originalChannelId , originalMessageId);