fix commentcount

This commit is contained in:
_Bastler 2021-10-06 19:04:14 +02:00
parent cdcdb64d60
commit 33ace4db2a
1 changed files with 19 additions and 17 deletions

View File

@ -46,12 +46,12 @@ public class CommentManager {
* Fetch by date. * Fetch by date.
* *
* @param username the username * @param username the username
* @param target the target * @param target the target
* @param parent the parent * @param parent the parent
* @param date the date * @param date the date
* @param page the page * @param page the page
* @param size the size * @param size the size
* @param desc the desc * @param desc the desc
* @return the page * @return the page
*/ */
public Page<Comment> fetchByDate(String username, Long target, Long parent, Instant date, public Page<Comment> fetchByDate(String username, Long target, Long parent, Instant date,
@ -72,11 +72,11 @@ public class CommentManager {
* Fetch by username. * Fetch by username.
* *
* @param username the username * @param username the username
* @param orElse the or else * @param orElse the or else
* @param date the date * @param date the date
* @param page the page * @param page the page
* @param size the size * @param size the size
* @param asc the asc * @param asc the asc
* @return the page * @return the page
*/ */
public Page<Comment> fetchByUsername(String username, Long orElse, Instant date, int page, public Page<Comment> fetchByUsername(String username, Long orElse, Instant date, int page,
@ -99,7 +99,8 @@ public class CommentManager {
return count(target); 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 * @return the long
*/ */
public Long count(Long target) { 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. * Apply metadata.
* *
* @param username the username * @param username the username
* @param comment the comment * @param comment the comment
* @param ignore the ignore * @param ignore the ignore
*/ */
public void applyMetadata(String username, Comment comment, List<String> ignore) { public void applyMetadata(String username, Comment comment, List<String> ignore) {
@ -168,8 +170,8 @@ public class CommentManager {
* Apply metadata. * Apply metadata.
* *
* @param username the username * @param username the username
* @param entries the entries * @param entries the entries
* @param ignore the ignore * @param ignore the ignore
*/ */
public void applyMetadata(String username, List<Comment> entries, List<String> ignore) { public void applyMetadata(String username, List<Comment> entries, List<String> ignore) {
for (Comment comment : entries) { for (Comment comment : entries) {