From 33ace4db2a9f98a673050205fe28117ac0c85037 Mon Sep 17 00:00:00 2001 From: _Bastler Date: Wed, 6 Oct 2021 19:04:14 +0200 Subject: [PATCH] fix commentcount --- .../board/businesslogic/CommentManager.java | 36 ++++++++++--------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/src/main/java/de/bstly/board/businesslogic/CommentManager.java b/src/main/java/de/bstly/board/businesslogic/CommentManager.java index 53ff11c..9e40d5a 100644 --- a/src/main/java/de/bstly/board/businesslogic/CommentManager.java +++ b/src/main/java/de/bstly/board/businesslogic/CommentManager.java @@ -46,12 +46,12 @@ public class CommentManager { * Fetch by date. * * @param username the username - * @param target the target - * @param parent the parent - * @param date the date - * @param page the page - * @param size the size - * @param desc the desc + * @param target the target + * @param parent the parent + * @param date the date + * @param page the page + * @param size the size + * @param desc the desc * @return the page */ public Page fetchByDate(String username, Long target, Long parent, Instant date, @@ -72,11 +72,11 @@ public class CommentManager { * Fetch by username. * * @param username the username - * @param orElse the or else - * @param date the date - * @param page the page - * @param size the size - * @param asc the asc + * @param orElse the or else + * @param date the date + * @param page the page + * @param size the size + * @param asc the asc * @return the page */ public Page fetchByUsername(String username, Long orElse, Instant date, int page, @@ -99,7 +99,8 @@ public class CommentManager { return count(target); } - return commentRepository.count(qComment.target.eq(target).and(qComment.parent.eq(parent))); + return commentRepository.count(qComment.target.eq(target).and(qComment.parent.eq(parent)) + .and(qComment.created.before(Instant.now()))); } /** @@ -109,15 +110,16 @@ public class CommentManager { * @return the long */ public Long count(Long target) { - return commentRepository.count(qComment.target.eq(target)); + return commentRepository + .count(qComment.target.eq(target).and(qComment.created.before(Instant.now()))); } /** * Apply metadata. * * @param username the username - * @param comment the comment - * @param ignore the ignore + * @param comment the comment + * @param ignore the ignore */ public void applyMetadata(String username, Comment comment, List ignore) { @@ -168,8 +170,8 @@ public class CommentManager { * Apply metadata. * * @param username the username - * @param entries the entries - * @param ignore the ignore + * @param entries the entries + * @param ignore the ignore */ public void applyMetadata(String username, List entries, List ignore) { for (Comment comment : entries) {