#20900: Creating Indexing tasks by batches

Work Item: 20900
This commit is contained in:
Sebastien Ros
2014-09-18 15:39:03 -07:00
parent a0e8fda8a2
commit c590337df1
@@ -63,9 +63,21 @@ namespace Orchard.Indexing.Settings {
}
private void CreateTasksForType(string type) {
foreach (var contentItem in _contentManager.Query(VersionOptions.Published, new [] { type }).List()) {
_indexingTaskManager.CreateUpdateIndexTask(contentItem);
}
var index = 0;
bool contentItemProcessed;
// todo: load ids only, or create a queued job
do {
contentItemProcessed = false;
var contentItemsToIndex = _contentManager.Query(VersionOptions.Published, new [] { type }).Slice(index, 50);
foreach (var contentItem in contentItemsToIndex) {
contentItemProcessed = true;
_indexingTaskManager.CreateUpdateIndexTask(contentItem);
}
} while (contentItemProcessed);
}
}
}