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:
Athou
2013-08-01 21:11:45 +02:00
parent cb1b99815c
commit 71403d4174
3 changed files with 42 additions and 9 deletions

View File

@@ -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;
}
}
}