This commit is contained in:
_Bastler 2021-12-01 19:25:33 +01:00
parent a53db5afbf
commit 922cf5597e
3 changed files with 69 additions and 54 deletions

View File

@ -95,14 +95,14 @@ public class EntryManager {
/**
* Fetch by ranking.
*
* @param username the username
* @param date the date
* @param username the username
* @param date the date
* @param flaggedStatus the flagged status
* @param tag the tag
* @param gravity the gravity
* @param page the page
* @param size the size
* @param asc the asc
* @param tag the tag
* @param gravity the gravity
* @param page the page
* @param size the size
* @param asc the asc
* @return the page
*/
public Page<Entry> fetchByRanking(String username, Instant date, FlaggedStatus flaggedStatus,
@ -122,13 +122,13 @@ public class EntryManager {
/**
* Fetch by date.
*
* @param username the username
* @param date the date
* @param username the username
* @param date the date
* @param flaggedStatus the flagged status
* @param tag the tag
* @param page the page
* @param size the size
* @param asc the asc
* @param tag the tag
* @param page the page
* @param size the size
* @param asc the asc
* @return the page
*/
public Page<Entry> fetchByDate(String username, Instant date, FlaggedStatus flaggedStatus,
@ -147,14 +147,14 @@ public class EntryManager {
/**
* Fetch by comments.
*
* @param username the username
* @param date the date
* @param username the username
* @param date the date
* @param flaggedStatus the flagged status
* @param tag the tag
* @param gravity the gravity
* @param page the page
* @param size the size
* @param asc the asc
* @param tag the tag
* @param gravity the gravity
* @param page the page
* @param size the size
* @param asc the asc
* @return the page
*/
public Page<Entry> fetchByComments(String username, Instant date, FlaggedStatus flaggedStatus,
@ -175,13 +175,13 @@ public class EntryManager {
/**
* Fetch by last comment.
*
* @param username the username
* @param date the date
* @param username the username
* @param date the date
* @param flaggedStatus the flagged status
* @param tag the tag
* @param page the page
* @param size the size
* @param asc the asc
* @param tag the tag
* @param page the page
* @param size the size
* @param asc the asc
* @return the page
*/
public Page<Entry> fetchByLastComment(String username, Instant date,
@ -201,14 +201,14 @@ public class EntryManager {
/**
* Fetch by user.
*
* @param fromUser the from user
* @param username the username
* @param date the date
* @param fromUser the from user
* @param username the username
* @param date the date
* @param flaggedStatus the flagged status
* @param tag the tag
* @param page the page
* @param size the size
* @param asc the asc
* @param tag the tag
* @param page the page
* @param size the size
* @param asc the asc
* @return the page
*/
public Page<Entry> fetchByUser(String fromUser, String username, Instant date,
@ -230,13 +230,13 @@ public class EntryManager {
/**
* Creates the entry query.
*
* @param rawQuery the raw query
* @param username the username
* @param date the date
* @param rawQuery the raw query
* @param username the username
* @param date the date
* @param flaggedStatus the flagged status
* @param tag the tag
* @param additional the additional
* @param orderBy the order by
* @param tag the tag
* @param additional the additional
* @param orderBy the order by
* @return the query
*/
protected Query createEntryQuery(String rawQuery, String username, Instant date,
@ -284,12 +284,12 @@ public class EntryManager {
/**
* Creates the count query.
*
* @param rawQuery the raw query
* @param username the username
* @param date the date
* @param rawQuery the raw query
* @param username the username
* @param date the date
* @param flaggedStatus the flagged status
* @param tag the tag
* @param additional the additional
* @param tag the tag
* @param additional the additional
* @return the query
*/
protected Query createCountQuery(String rawQuery, String username, Instant date,
@ -333,7 +333,7 @@ public class EntryManager {
*
* @param page the page
* @param size the size
* @param asc the asc
* @param asc the asc
* @return the page
*/
public Page<Entry> fetchFlagged(int page, int size, boolean asc) {
@ -352,8 +352,8 @@ public class EntryManager {
* Fetch by bookmarks.
*
* @param username the username
* @param page the page
* @param size the size
* @param page the page
* @param size the size
* @return the page
*/
public Page<Entry> fetchByBookmarks(String username, int page, int size) {
@ -371,9 +371,9 @@ public class EntryManager {
* Apply metadata.
*
* @param username the username
* @param karma the karma
* @param entry the entry
* @param ignore the ignore
* @param karma the karma
* @param entry the entry
* @param ignore the ignore
*/
public void applyMetadata(String username, long karma, Entry entry, List<String> ignore) {
@ -458,9 +458,9 @@ public class EntryManager {
* Apply metadata.
*
* @param username the username
* @param karma the karma
* @param entries the entries
* @param ignore the ignore
* @param karma the karma
* @param entries the entries
* @param ignore the ignore
*/
public void applyMetadata(String username, long karma, List<Entry> entries,
List<String> ignore) {
@ -497,6 +497,11 @@ public class EntryManager {
*/
public Entry save(Entry entry) {
List<String> tags = Lists.newArrayList(entry.getTags());
if (tags.size() > settingsManager.getMaxTags()) {
tags = tags.subList(0, settingsManager.getMaxTags() - 1);
}
entry = entryRepository.save(entry);
tagManager.setForTarget(entry.getId(), tags);
return entry;
@ -533,7 +538,7 @@ public class EntryManager {
/**
* Gets the user points.
*
* @param entryId the entry id
* @param entryId the entry id
* @param username the username
* @return the user points
*/

View File

@ -24,6 +24,8 @@ public class SettingsManager {
private long UNVOTE_THRESH;
@Value("${bstly.board.flagThresh:3}")
private long FLAG_THRESH;
@Value("${bstly.board.maxTags:3}")
private int MAX_TAGS;
/**
* Gets the gravity.
@ -78,4 +80,11 @@ public class SettingsManager {
public long getFlahThresh() {
return FLAG_THRESH;
}
/**
* @return
*/
public int getMaxTags() {
return MAX_TAGS;
}
}

View File

@ -36,6 +36,7 @@ public class SettingsController extends BaseController {
settings.put("pageSize", getPageSize());
settings.put("entryDelay", getEntryDelay());
settings.put("commentDelay", getCommentDelay());
settings.put("maxTags", settingsManager.getMaxTags());
settings.put("defaultGravity", settingsManager.getGravity());
settings.put("defaultPageSize", settingsManager.getPageSize());
settings.put("defaultEntryDelay", settingsManager.getEntryDelay());