Fixed InProgress to properly respect order and show more recent activity first. Issue is with IEntityDate LastModified not updating in DataContext.

This commit is contained in:
Joseph Milazzo 2021-04-01 12:15:04 -05:00
parent 876466d05b
commit 1f5d1eca1d
2 changed files with 11 additions and 6 deletions

View File

@ -1,4 +1,5 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
@ -19,14 +20,16 @@ namespace API.Controllers
private readonly ICacheService _cacheService;
private readonly ILogger<ReaderController> _logger;
private readonly IUnitOfWork _unitOfWork;
private readonly DataContext _dataContext;
public ReaderController(IDirectoryService directoryService, ICacheService cacheService,
ILogger<ReaderController> logger, IUnitOfWork unitOfWork)
ILogger<ReaderController> logger, IUnitOfWork unitOfWork, DataContext dataContext)
{
_directoryService = directoryService;
_cacheService = cacheService;
_logger = logger;
_unitOfWork = unitOfWork;
_dataContext = dataContext;
}
[HttpGet("image")]
@ -218,7 +221,8 @@ namespace API.Controllers
PagesRead = bookmarkDto.PageNum,
VolumeId = bookmarkDto.VolumeId,
SeriesId = bookmarkDto.SeriesId,
ChapterId = bookmarkDto.ChapterId
ChapterId = bookmarkDto.ChapterId,
LastModified = DateTime.Now
});
}
else
@ -226,8 +230,9 @@ namespace API.Controllers
userProgress.PagesRead = bookmarkDto.PageNum;
userProgress.SeriesId = bookmarkDto.SeriesId;
userProgress.VolumeId = bookmarkDto.VolumeId;
userProgress.LastModified = DateTime.Now;
}
_unitOfWork.UserRepository.Update(user);
if (await _unitOfWork.Complete())

View File

@ -315,13 +315,13 @@ namespace API.Data
&& s.PagesRead > 0
&& s.PagesRead < s.Series.Pages
&& (libraryId <= 0 || s.Series.LibraryId == libraryId))
.OrderByDescending(s => s.LastModified)
.Take(limit)
.Select(s => s.Series.Id);
var series = await _context.Series
.Where(s => seriesWithProgress.Contains(s.Id))
.OrderByDescending(s => s.LastModified)
.Take(limit)
.ProjectTo<SeriesDto>(_mapper.ConfigurationProvider)
.AsNoTracking()
.ToListAsync();