fix usercomments

This commit is contained in:
_Bastler 2021-10-06 13:16:30 +02:00
parent 7e0c292d7c
commit 06e402a8f2
1 changed files with 21 additions and 23 deletions

View File

@ -45,12 +45,12 @@ public class CommentManager {
/** /**
* Fetch by ranking. * Fetch by ranking.
* *
* @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 gravity the gravity * @param gravity the gravity
* @param page the page * @param page the page
* @param size the size * @param size the size
* @return the page * @return the page
*/ */
@ -70,10 +70,10 @@ public class CommentManager {
* *
* @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(Long target, Long parent, Instant date, int page, int size, public Page<Comment> fetchByDate(Long target, Long parent, Instant date, int page, int size,
@ -95,21 +95,19 @@ 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,
int size, boolean asc) { int size, boolean asc) {
Sort sort = Sort.by(asc ? Order.asc("created") : Order.desc("created")); Sort sort = Sort.by(asc ? Order.asc("created") : Order.desc("created"));
return commentRepository return commentRepository.findAll(
.findAll( qComment.author.equalsIgnoreCase(username).and(qComment.created.before(date)),
qComment.author.equalsIgnoreCase(username).and(qComment.parent.isNull()) PageRequest.of(page, size, sort));
.and(qComment.created.before(date)),
PageRequest.of(page, size, sort));
} }
/** /**
@ -141,8 +139,8 @@ public class CommentManager {
* 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) {
@ -193,8 +191,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) {