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:
parent
e6cfa4feca
commit
606e4c8b12
4 changed files with 25 additions and 16 deletions
|
@ -148,13 +148,22 @@ namespace API.Controllers
|
|||
}
|
||||
|
||||
[HttpGet("recently-added")]
|
||||
public async Task<ActionResult<IEnumerable<SeriesDto>>> GetRecentlyAdded(int libraryId = 0, int limit = 20)
|
||||
public async Task<ActionResult<IEnumerable<SeriesDto>>> GetRecentlyAdded([FromQuery] UserParams userParams, int libraryId = 0)
|
||||
{
|
||||
var user = await _unitOfWork.UserRepository.GetUserByUsernameAsync(User.GetUsername());
|
||||
if (user == null) return Ok(Array.Empty<SeriesDto>());
|
||||
return Ok(await _unitOfWork.SeriesRepository.GetRecentlyAdded(user.Id, libraryId, limit));
|
||||
var series =
|
||||
await _unitOfWork.SeriesRepository.GetRecentlyAdded(libraryId, user.Id, userParams);
|
||||
|
||||
// Apply progress/rating information (I can't work out how to do this in initial query)
|
||||
if (series == null) return BadRequest("Could not get series");
|
||||
|
||||
await _unitOfWork.SeriesRepository.AddSeriesModifiers(user.Id, series);
|
||||
|
||||
Response.AddPaginationHeader(series.CurrentPage, series.PageSize, series.TotalCount, series.TotalPages);
|
||||
|
||||
return Ok(series);
|
||||
}
|
||||
|
||||
|
||||
[HttpGet("in-progress")]
|
||||
public async Task<ActionResult<IEnumerable<SeriesDto>>> GetInProgress(int libraryId = 0, int limit = 20)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue