Changes recycle bin service queries to paged

This commit is contained in:
Shannon
2018-11-01 10:22:45 +11:00
parent 082d860a5b
commit 76a8cd6dcf
6 changed files with 21 additions and 17 deletions

View File

@@ -141,11 +141,11 @@ namespace Umbraco.Core.Services
/// </summary>
IEnumerable<IContent> GetContentForRelease();
//fixme: should be paged
/// <summary>
/// Gets documents in the recycle bin.
/// </summary>
IEnumerable<IContent> GetContentInRecycleBin();
IEnumerable<IContent> GetPagedContentInRecycleBin(long pageIndex, int pageSize, out long totalRecords,
IQuery<IContent> filter = null, Ordering ordering = null);
/// <summary>
/// Gets child documents of a parent.

View File

@@ -170,7 +170,8 @@ namespace Umbraco.Core.Services
/// Gets a collection of an <see cref="IMedia"/> objects, which resides in the Recycle Bin
/// </summary>
/// <returns>An Enumerable list of <see cref="IMedia"/> objects</returns>
IEnumerable<IMedia> GetMediaInRecycleBin();
IEnumerable<IMedia> GetPagedMediaInRecycleBin(long pageIndex, int pageSize, out long totalRecords,
IQuery<IMedia> filter = null, Ordering ordering = null);
/// <summary>
/// Moves an <see cref="IMedia"/> object to a new location

View File

@@ -727,13 +727,17 @@ namespace Umbraco.Core.Services.Implement
/// Gets a collection of an <see cref="IContent"/> objects, which resides in the Recycle Bin
/// </summary>
/// <returns>An Enumerable list of <see cref="IContent"/> objects</returns>
public IEnumerable<IContent> GetContentInRecycleBin()
public IEnumerable<IContent> GetPagedContentInRecycleBin(long pageIndex, int pageSize, out long totalRecords,
IQuery<IContent> filter = null, Ordering ordering = null)
{
using (var scope = ScopeProvider.CreateScope(autoComplete: true))
{
if (ordering == null)
ordering = Ordering.By("Path");
scope.ReadLock(Constants.Locks.ContentTree);
var query = Query<IContent>().Where(x => x.Path.StartsWith(Constants.System.RecycleBinContentPathPrefix));
return _documentRepository.Get(query);
return _documentRepository.GetPage(query, pageIndex, pageSize, out totalRecords, filter, ordering);
}
}

View File

@@ -643,17 +643,18 @@ namespace Umbraco.Core.Services.Implement
}
}
/// <summary>
/// Gets a collection of an <see cref="IMedia"/> objects, which resides in the Recycle Bin
/// </summary>
/// <returns>An Enumerable list of <see cref="IMedia"/> objects</returns>
public IEnumerable<IMedia> GetMediaInRecycleBin()
/// <inheritdoc />
public IEnumerable<IMedia> GetPagedMediaInRecycleBin(long pageIndex, int pageSize, out long totalRecords,
IQuery<IMedia> filter = null, Ordering ordering = null)
{
using (var scope = ScopeProvider.CreateScope(autoComplete: true))
{
if (ordering == null)
ordering = Ordering.By("Path");
scope.ReadLock(Constants.Locks.MediaTree);
var query = Query<IMedia>().Where(x => x.Path.StartsWith(Constants.System.RecycleBinMediaPathPrefix));
return _mediaRepository.Get(query);
return _mediaRepository.GetPage(query, pageIndex, pageSize, out totalRecords, filter, ordering);
}
}

View File

@@ -133,8 +133,6 @@ namespace Umbraco.Tests.Persistence.NPocoTests
contentService.GetContentForRelease();
contentService.GetContentInRecycleBin();
((ContentService)contentService).GetPublishedDescendants(new Content("Test", -1, new ContentType(-1))
{
Id = id1,

View File

@@ -1172,7 +1172,7 @@ namespace Umbraco.Tests.Services
var contentService = ServiceContext.ContentService;
// Act
var contents = contentService.GetContentInRecycleBin().ToList();
var contents = contentService.GetPagedContentInRecycleBin(0, int.MaxValue, out var _).ToList();
// Assert
Assert.That(contents, Is.Not.Null);
@@ -1792,7 +1792,7 @@ namespace Umbraco.Tests.Services
Assert.True(descendants.All(x => x.Trashed));
contentService.EmptyRecycleBin();
var trashed = contentService.GetContentInRecycleBin();
var trashed = contentService.GetPagedContentInRecycleBin(0, int.MaxValue, out var _).ToList();
Assert.IsEmpty(trashed);
}
@@ -1804,7 +1804,7 @@ namespace Umbraco.Tests.Services
// Act
contentService.EmptyRecycleBin();
var contents = contentService.GetContentInRecycleBin();
var contents = contentService.GetPagedContentInRecycleBin(0, int.MaxValue, out var _).ToList();
// Assert
Assert.That(contents.Any(), Is.False);
@@ -1982,7 +1982,7 @@ namespace Umbraco.Tests.Services
// Act
ServiceContext.ContentService.MoveToRecycleBin(content1);
ServiceContext.ContentService.EmptyRecycleBin();
var contents = ServiceContext.ContentService.GetContentInRecycleBin();
var contents = ServiceContext.ContentService.GetPagedContentInRecycleBin(0, int.MaxValue, out var _).ToList();
// Assert
Assert.That(contents.Any(), Is.False);