userkarma

This commit is contained in:
2021-10-04 18:29:04 +02:00
parent 8b0fab7488
commit 1a9f582967
3 changed files with 36 additions and 7 deletions
@@ -218,4 +218,21 @@ public class EntryManager {
return upvotes - downvotes;
}
/**
* Gets the user points.
*
* @param entryId the entry id
* @param username the username
* @return the user points
*/
public long getUserPoints(Long entryId, String username) {
long upvotes = voteRepository.count(qVote.targetType.eq(Types.entry)
.and(qVote.type.eq(VoteType.up).and(qVote.author.ne(username)))
.and(qVote.target.eq(entryId)));
long downvotes = voteRepository.count(qVote.targetType.eq(Types.entry)
.and(qVote.type.eq(VoteType.down).and(qVote.author.ne(username)))
.and(qVote.target.eq(entryId)));
return upvotes - downvotes;
}
}