Fix small bug in index provider

Also cleanup the API a bit
Also provide more detailled statistics about the search index on the
"Search Index Management" page.

--HG--
branch : dev
This commit is contained in:
Renaud Paquay
2010-07-11 12:11:38 -07:00
parent 2761c3520b
commit 5a7724e2e1
9 changed files with 65 additions and 37 deletions

View File

@@ -59,14 +59,14 @@ namespace Orchard.Indexing.Services {
_indexProvider = _indexManager.GetSearchIndexProvider();
var updateIndexDocuments = new List<IDocumentIndex>();
DateTime lastIndexing;
DateTime? lastIndexUtc;
// Do we need to rebuild the full index (first time module is used, or rebuild index requested) ?
if (_indexProvider.IsEmpty(SearchIndexName)) {
Logger.Information("Rebuild index started");
// mark current last task, as we should process older ones (in case of rebuild index only)
lastIndexing = _indexingTaskManager.GetLastTaskDateTime();
lastIndexUtc = _indexingTaskManager.GetLastTaskDateTime();
// get every existing content item to index it
foreach (var contentItem in _contentManager.Query(VersionOptions.Published).List()) {
@@ -91,15 +91,15 @@ namespace Orchard.Indexing.Services {
}
else {
// retrieve last processed index time
lastIndexing = _indexProvider.GetLastIndexUtc(SearchIndexName);
lastIndexUtc = _indexProvider.GetLastIndexUtc(SearchIndexName);
}
_indexProvider.SetLastIndexUtc(SearchIndexName, _clock.UtcNow);
// retrieve not yet processed tasks
var taskRecords = lastIndexing == DateTime.MinValue
var taskRecords = lastIndexUtc == null
? _repository.Fetch(x => true).ToArray()
: _repository.Fetch(x => x.CreatedUtc > lastIndexing).ToArray();
: _repository.Fetch(x => x.CreatedUtc > lastIndexUtc).ToArray();
// nothing to do ?