mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-27 04:19:04 +08:00
Removing residual files accidentally brought back during merge in Orchard.Indexing
This commit is contained in:
@@ -1,7 +0,0 @@
|
||||
namespace Orchard.Indexing.Models {
|
||||
public class IndexTaskBatchRecord {
|
||||
public virtual int Id { get; set; }
|
||||
public virtual int BatchStartIndex { get; set; }
|
||||
public virtual string ContentType { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
using System.Linq;
|
||||
using Orchard.Tasks;
|
||||
using Orchard.Tasks.Indexing;
|
||||
|
||||
namespace Orchard.Indexing.Services {
|
||||
public class CreateUpdateIndexTaskBackgroundTask : IBackgroundTask {
|
||||
private readonly IIndexTaskBatchManagementService _indexTaskBatchManagementService;
|
||||
private readonly IIndexingTaskManager _indexingTaskManager;
|
||||
|
||||
public CreateUpdateIndexTaskBackgroundTask(IIndexTaskBatchManagementService indexTaskBatchManagementService, IIndexingTaskManager indexingTaskManager) {
|
||||
_indexTaskBatchManagementService = indexTaskBatchManagementService;
|
||||
_indexingTaskManager = indexingTaskManager;
|
||||
}
|
||||
|
||||
public void Sweep() {
|
||||
var contentItemsLists = _indexTaskBatchManagementService.GetNextBatchOfContentItemsToIndex();
|
||||
|
||||
foreach (var contentItemsList in contentItemsLists) {
|
||||
foreach (var contentItem in contentItemsList) {
|
||||
_indexingTaskManager.CreateUpdateIndexTask(contentItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using Orchard.ContentManagement;
|
||||
|
||||
namespace Orchard.Indexing.Services {
|
||||
/// <summary>
|
||||
/// Manages the batches for indexing tasks.
|
||||
/// </summary>
|
||||
public interface IIndexTaskBatchManagementService : IDependency {
|
||||
|
||||
/// <summary>
|
||||
/// Registers a content type for the <see cref="CreateUpdateIndexTaskBackgroundTask"/>.
|
||||
/// </summary>
|
||||
/// <param name="contentType">The content type.</param>
|
||||
void RegisterContentType(string contentType);
|
||||
|
||||
/// <summary>
|
||||
/// Returns a list of a list of the registered content items.
|
||||
/// </summary>
|
||||
IEnumerable<IEnumerable<ContentItem>> GetNextBatchOfContentItemsToIndex();
|
||||
}
|
||||
}
|
||||
@@ -1,53 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.Data;
|
||||
using Orchard.Indexing.Models;
|
||||
|
||||
namespace Orchard.Indexing.Services {
|
||||
public class IndexTaskBatchManagementService : IIndexTaskBatchManagementService {
|
||||
private readonly IRepository<IndexTaskBatchRecord> _indexTaskBatchRecordRepository;
|
||||
private readonly IContentManager _contentManager;
|
||||
|
||||
private const int BatchSize = 50;
|
||||
|
||||
public IndexTaskBatchManagementService(IRepository<IndexTaskBatchRecord> indexTaskBatchRecordRepository, IContentManager contentManager) {
|
||||
_indexTaskBatchRecordRepository = indexTaskBatchRecordRepository;
|
||||
_contentManager = contentManager;
|
||||
}
|
||||
|
||||
public void RegisterContentType(string contentType) {
|
||||
var registeredContentType = _indexTaskBatchRecordRepository.Table.Where(i => i.ContentType == contentType).FirstOrDefault();
|
||||
|
||||
if (registeredContentType == null) {
|
||||
_indexTaskBatchRecordRepository.Create(new IndexTaskBatchRecord { ContentType = contentType, BatchStartIndex = 0 });
|
||||
}
|
||||
else {
|
||||
registeredContentType.BatchStartIndex = 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public IEnumerable<IEnumerable<ContentItem>> GetNextBatchOfContentItemsToIndex() {
|
||||
var indexTaskBatchRecords = _indexTaskBatchRecordRepository.Table;
|
||||
if (indexTaskBatchRecords == null) return null;
|
||||
|
||||
var contentItemsList = new List<List<ContentItem>>();
|
||||
|
||||
foreach (var indexTaskBatchRecord in indexTaskBatchRecords) {
|
||||
var contentItems = _contentManager.Query(indexTaskBatchRecord.ContentType).Slice(indexTaskBatchRecord.BatchStartIndex, BatchSize).ToList();
|
||||
|
||||
if (contentItems.Any()) contentItemsList.Add(contentItems);
|
||||
|
||||
if (contentItems.Count == 0 || contentItems.Count < BatchSize) {
|
||||
_indexTaskBatchRecordRepository.Delete(_indexTaskBatchRecordRepository.Table.FirstOrDefault(i => i.ContentType == indexTaskBatchRecord.ContentType));
|
||||
}
|
||||
else {
|
||||
indexTaskBatchRecord.BatchStartIndex += BatchSize;
|
||||
}
|
||||
}
|
||||
|
||||
return contentItemsList;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user