refactor naming + user
This commit is contained in:
@@ -50,19 +50,16 @@ public class EntryManager {
|
||||
@Value("${bstly.board.ranking.gravity:1.8}")
|
||||
private double GRAVITY;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Direct fetch by ranking.
|
||||
* Fetch by ranking.
|
||||
*
|
||||
* @param date the date
|
||||
* @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
|
||||
*/
|
||||
public Page<RankedEntry> fetchByRanking(Instant date, double gravity, int page,
|
||||
int size) {
|
||||
public Page<RankedEntry> fetchByRanking(Instant date, double gravity, int page, int size) {
|
||||
return entryRepository.findAllByRanking(date, gravity, PageRequest.of(page, size));
|
||||
}
|
||||
|
||||
@@ -80,12 +77,28 @@ public class EntryManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the entries.
|
||||
* Fetch by user.
|
||||
*
|
||||
* @param username the username
|
||||
* @param page the page
|
||||
* @param size the size
|
||||
* @return the entries
|
||||
* @param date the date
|
||||
* @param page the page
|
||||
* @param size the size
|
||||
* @param asc the asc
|
||||
* @return the page
|
||||
*/
|
||||
public Page<Entry> fetchByUser(String username, Instant date, int page, int size, boolean asc) {
|
||||
Sort sort = Sort.by(asc ? Order.asc("created") : Order.desc("created"));
|
||||
return entryRepository.findAll(qEntry.author.eq(username).and(qEntry.created.before(date)),
|
||||
PageRequest.of(page, size, sort));
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch by bookmarks.
|
||||
*
|
||||
* @param username the username
|
||||
* @param page the page
|
||||
* @param size the size
|
||||
* @return the page
|
||||
*/
|
||||
public Page<Entry> fetchByBookmarks(String username, int page, int size) {
|
||||
Bookmarks bookmarks = bookmarksManager.get(username);
|
||||
@@ -102,7 +115,7 @@ public class EntryManager {
|
||||
* Apply metadata.
|
||||
*
|
||||
* @param username the username
|
||||
* @param entry the entry
|
||||
* @param entry the entry
|
||||
*/
|
||||
public void applyMetadata(String username, Entry entry) {
|
||||
if (!entry.getMetadata().containsKey("comments")) {
|
||||
@@ -142,7 +155,7 @@ public class EntryManager {
|
||||
* Apply metadata.
|
||||
*
|
||||
* @param username the username
|
||||
* @param entries the entries
|
||||
* @param entries the entries
|
||||
*/
|
||||
public void applyMetadata(String username, List<Entry> entries) {
|
||||
for (Entry entry : entries) {
|
||||
|
||||
Reference in New Issue
Block a user