Recently Added Page (#261)

- Updated route task for 'recently-added'.
- Refactored GetRecentlyAdded task instead of creating new API task. This way is more efficient and prevents bloat.
- Adding pageSize to UserParams.cs (got lost in PRs).
This commit is contained in:
Robbie Davis 2021-06-04 11:09:33 -04:00 committed by GitHub
parent e6cfa4feca
commit 606e4c8b12
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 25 additions and 16 deletions

View file

@ -291,7 +291,7 @@ namespace API.Data
/// <param name="libraryId">Library to restrict to, if 0, will apply to all libraries</param>
/// <param name="limit">How many series to pick.</param>
/// <returns></returns>
public async Task<IEnumerable<SeriesDto>> GetRecentlyAdded(int userId, int libraryId, int limit)
public async Task<PagedList<SeriesDto>> GetRecentlyAdded(int libraryId, int userId, UserParams userParams)
{
if (libraryId == 0)
{
@ -301,25 +301,25 @@ namespace API.Data
.AsNoTracking()
.Select(library => library.Id)
.ToList();
return await _context.Series
var allQuery = _context.Series
.Where(s => userLibraries.Contains(s.LibraryId))
.AsNoTracking()
.OrderByDescending(s => s.Created)
.Take(limit)
.ProjectTo<SeriesDto>(_mapper.ConfigurationProvider)
.ToListAsync();
.AsNoTracking();
return await PagedList<SeriesDto>.CreateAsync(allQuery, userParams.PageNumber, userParams.PageSize);
}
return await _context.Series
var query = _context.Series
.Where(s => s.LibraryId == libraryId)
.AsNoTracking()
.OrderByDescending(s => s.Created)
.Take(limit)
.ProjectTo<SeriesDto>(_mapper.ConfigurationProvider)
.ToListAsync();
.AsNoTracking();
return await PagedList<SeriesDto>.CreateAsync(query, userParams.PageNumber, userParams.PageSize);
}
/// <summary>