refactor naming + user
This commit is contained in:
@@ -43,12 +43,12 @@ public class CommentManager {
|
||||
/**
|
||||
* Fetch by ranking.
|
||||
*
|
||||
* @param target the target
|
||||
* @param parent the parent
|
||||
* @param date the date
|
||||
* @param target the target
|
||||
* @param parent the parent
|
||||
* @param date the date
|
||||
* @param gravity the gravity
|
||||
* @param page the page
|
||||
* @param size the size
|
||||
* @param page the page
|
||||
* @param size the size
|
||||
* @return the page
|
||||
*/
|
||||
|
||||
@@ -68,23 +68,43 @@ public class CommentManager {
|
||||
*
|
||||
* @param target the target
|
||||
* @param parent the parent
|
||||
* @param date the date
|
||||
* @param page the page
|
||||
* @param size the size
|
||||
* @param date the date
|
||||
* @param page the page
|
||||
* @param size the size
|
||||
* @param desc the desc
|
||||
* @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,
|
||||
boolean desc) {
|
||||
Sort sort = Sort.by(desc ? Order.desc("created") : Order.asc("created"));
|
||||
if (parent == null) {
|
||||
return commentRepository.findAll(
|
||||
qComment.target.eq(target).and(qComment.parent.isNull())
|
||||
.and(qComment.created.before(date)),
|
||||
PageRequest.of(page, size, Sort.by(Order.asc("created"))));
|
||||
return commentRepository
|
||||
.findAll(
|
||||
qComment.target.eq(target).and(qComment.parent.isNull())
|
||||
.and(qComment.created.before(date)),
|
||||
PageRequest.of(page, size, sort));
|
||||
}
|
||||
|
||||
return commentRepository.findAll(
|
||||
qComment.target.eq(target).and(qComment.parent.eq(parent))
|
||||
.and(qComment.created.before(date)),
|
||||
PageRequest.of(page, size, Sort.by(Order.asc("created"))));
|
||||
return commentRepository.findAll(qComment.target.eq(target).and(qComment.parent.eq(parent))
|
||||
.and(qComment.created.before(date)), PageRequest.of(page, size, sort));
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
* @return the page
|
||||
*/
|
||||
public Page<Comment> fetchByUsername(String username, Long orElse, Instant date, int page,
|
||||
int size, boolean asc) {
|
||||
Sort sort = Sort.by(asc ? Order.asc("created") : Order.desc("created"));
|
||||
return commentRepository.findAll(qComment.author.eq(username).and(qComment.parent.isNull())
|
||||
.and(qComment.created.before(date)), PageRequest.of(page, size, sort));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -116,7 +136,7 @@ public class CommentManager {
|
||||
* Apply metadata.
|
||||
*
|
||||
* @param username the username
|
||||
* @param comment the comment
|
||||
* @param comment the comment
|
||||
*/
|
||||
public void applyMetadata(String username, Comment comment) {
|
||||
if (!comment.getMetadata().containsKey("comments")) {
|
||||
@@ -153,7 +173,7 @@ public class CommentManager {
|
||||
* Apply metadata.
|
||||
*
|
||||
* @param username the username
|
||||
* @param entries the entries
|
||||
* @param entries the entries
|
||||
*/
|
||||
public void applyMetadata(String username, List<Comment> entries) {
|
||||
for (Comment comment : entries) {
|
||||
|
||||
Reference in New Issue
Block a user