Gets indexes updating based on content type changes

This commit is contained in:
Shannon
2018-10-30 17:32:27 +11:00
parent 9416c5f638
commit a383309e46
6 changed files with 105 additions and 60 deletions

View File

@@ -99,7 +99,7 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
private string VariantNameSqlExpression
=> SqlContext.VisitDto<ContentVersionCultureVariationDto, NodeDto>((ccv, node) => ccv.Name ?? node.Text, "ccv").Sql;
protected virtual Sql<ISqlContext> GetBaseQuery(QueryType queryType, bool current)
protected Sql<ISqlContext> GetBaseQuery(QueryType queryType, bool current)
{
var sql = SqlContext.Sql();

View File

@@ -79,9 +79,15 @@ namespace Umbraco.Core.Services
IEnumerable<IContent> GetByIds(IEnumerable<Guid> ids);
/// <summary>
/// Gets documents of a given document type.
/// Gets paged documents of a content content
/// </summary>
IEnumerable<IContent> GetByType(int documentTypeId);
/// <param name="contentType">The page number.</param>
/// <param name="pageIndex">The page number.</param>
/// <param name="pageSize">The page size.</param>
/// <param name="totalRecords">Total number of documents.</param>
/// <param name="filter">Search text filter.</param>
/// <param name="ordering">Ordering infos.</param>
IEnumerable<IContent> GetPagedOfType(int contentType, long pageIndex, int pageSize, out long totalRecords, IQuery<IContent> filter = null, Ordering ordering = null);
/// <summary>
/// Gets documents at a given level.

View File

@@ -405,28 +405,20 @@ namespace Umbraco.Core.Services.Implement
}
}
/// <summary>
/// Gets a collection of <see cref="IContent"/> objects by the Id of the <see cref="IContentType"/>
/// </summary>
/// <param name="id">Id of the <see cref="IContentType"/></param>
/// <returns>An Enumerable list of <see cref="IContent"/> objects</returns>
public IEnumerable<IContent> GetByType(int id)
public IEnumerable<IContent> GetPagedOfType(int contentTypeId, long pageIndex, int pageSize, out long totalRecords, IQuery<IContent> filter, Ordering ordering = null)
{
using (var scope = ScopeProvider.CreateScope(autoComplete: true))
{
scope.ReadLock(Constants.Locks.ContentTree);
var query = Query<IContent>().Where(x => x.ContentTypeId == id);
return _documentRepository.Get(query);
}
}
if(pageIndex < 0) throw new ArgumentOutOfRangeException(nameof(pageIndex));
if (pageSize <= 0) throw new ArgumentOutOfRangeException(nameof(pageSize));
if (ordering == null)
ordering = Ordering.By("sortOrder");
internal IEnumerable<IContent> GetPublishedContentOfContentType(int id)
{
using (var scope = ScopeProvider.CreateScope(autoComplete: true))
{
scope.ReadLock(Constants.Locks.ContentTree);
var query = Query<IContent>().Where(x => x.ContentTypeId == id);
return _documentRepository.Get(query);
return _documentRepository.GetPage(
Query<IContent>().Where(x => x.ContentTypeId == contentTypeId),
pageIndex, pageSize, out totalRecords, filter, ordering);
}
}