mirror of
https://github.com/Athou/commafeed.git
synced 2026-03-21 21:37:29 +00:00
first add feeds from the queue, then if needed fetch feeds from the database to fill the batch
This commit is contained in:
@@ -147,22 +147,25 @@ public class FeedRefreshTaskGiver {
|
|||||||
*/
|
*/
|
||||||
private void refill() {
|
private void refill() {
|
||||||
refill.mark();
|
refill.mark();
|
||||||
int count = Math.min(100, 3 * backgroundThreads);
|
|
||||||
|
|
||||||
// first, get feeds that are up to refresh from the database
|
|
||||||
List<FeedRefreshContext> contexts = Lists.newArrayList();
|
List<FeedRefreshContext> contexts = Lists.newArrayList();
|
||||||
if (!applicationSettingsService.get().isCrawlingPaused()) {
|
int batchSize = Math.min(100, 3 * backgroundThreads);
|
||||||
List<Feed> feeds = feedDAO.findNextUpdatable(count, getLastLoginThreshold());
|
|
||||||
for (Feed feed : feeds) {
|
// add feeds we got from the add() method
|
||||||
contexts.add(new FeedRefreshContext(feed, false));
|
int addQueueSize = addQueue.size();
|
||||||
}
|
for (int i = 0; i < Math.min(batchSize, addQueueSize); i++) {
|
||||||
|
contexts.add(addQueue.poll());
|
||||||
}
|
}
|
||||||
|
|
||||||
// then, add to those the feeds we got from the add() method. We add them at the beginning of the list as they probably have a
|
// add feeds that are up to refresh from the database
|
||||||
// higher priority
|
if (!applicationSettingsService.get().isCrawlingPaused()) {
|
||||||
int size = addQueue.size();
|
int count = batchSize - contexts.size();
|
||||||
for (int i = 0; i < Math.min(count, size); i++) {
|
if (count > 0) {
|
||||||
contexts.add(0, addQueue.poll());
|
List<Feed> feeds = feedDAO.findNextUpdatable(count, getLastLoginThreshold());
|
||||||
|
for (Feed feed : feeds) {
|
||||||
|
contexts.add(new FeedRefreshContext(feed, false));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// set the disabledDate to now as we use the disabledDate in feedDAO to decide what to refresh next. We also use a map to remove
|
// set the disabledDate to now as we use the disabledDate in feedDAO to decide what to refresh next. We also use a map to remove
|
||||||
@@ -178,8 +181,8 @@ public class FeedRefreshTaskGiver {
|
|||||||
takeQueue.addAll(map.values());
|
takeQueue.addAll(map.values());
|
||||||
|
|
||||||
// add feeds from the giveBack queue to the map, overriding duplicates
|
// add feeds from the giveBack queue to the map, overriding duplicates
|
||||||
size = giveBackQueue.size();
|
int giveBackQueueSize = giveBackQueue.size();
|
||||||
for (int i = 0; i < size; i++) {
|
for (int i = 0; i < giveBackQueueSize; i++) {
|
||||||
Feed feed = giveBackQueue.poll();
|
Feed feed = giveBackQueue.poll();
|
||||||
map.put(feed.getId(), new FeedRefreshContext(feed, false));
|
map.put(feed.getId(), new FeedRefreshContext(feed, false));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user