mirror of
https://github.com/Athou/commafeed.git
synced 2026-03-21 21:37:29 +00:00
if under heavy load, don't refresh feeds for users who logged in more than a month ago for the last time
This commit is contained in:
@@ -122,7 +122,7 @@ public class FeedRefreshTaskGiver {
|
||||
}
|
||||
|
||||
public Long getUpdatableCount() {
|
||||
return feedDAO.getUpdatableCount();
|
||||
return feedDAO.getUpdatableCount(getLastLoginThreshold());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -139,12 +139,12 @@ public class FeedRefreshTaskGiver {
|
||||
* refills the refresh queue and empties the giveBack queue while at it
|
||||
*/
|
||||
private void refill() {
|
||||
int count = Math.min(300, 3 * backgroundThreads);
|
||||
int count = Math.min(100, 3 * backgroundThreads);
|
||||
|
||||
// first, get feeds that are up to refresh from the database
|
||||
List<FeedRefreshContext> contexts = Lists.newArrayList();
|
||||
if (!applicationSettingsService.get().isCrawlingPaused()) {
|
||||
List<Feed> feeds = feedDAO.findNextUpdatable(count);
|
||||
List<Feed> feeds = feedDAO.findNextUpdatable(count, getLastLoginThreshold());
|
||||
for (Feed feed : feeds) {
|
||||
contexts.add(new FeedRefreshContext(feed, false));
|
||||
}
|
||||
@@ -195,4 +195,12 @@ public class FeedRefreshTaskGiver {
|
||||
giveBackQueue.add(feed);
|
||||
}
|
||||
|
||||
private Date getLastLoginThreshold() {
|
||||
if (applicationSettingsService.get().isHeavyLoad()) {
|
||||
return DateUtils.addDays(new Date(), -30);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user