Release Polish 3 (#3359)
This commit is contained in:
parent
dd3dec269f
commit
f812f61001
34 changed files with 211 additions and 134 deletions
|
@ -33,7 +33,7 @@ public interface IPersonRepository
|
|||
|
||||
Task<string> GetCoverImageAsync(int personId);
|
||||
Task<string?> GetCoverImageByNameAsync(string name);
|
||||
Task<IEnumerable<PersonRole>> GetRolesForPersonByName(string name, int userId);
|
||||
Task<IEnumerable<PersonRole>> GetRolesForPersonByName(int personId, int userId);
|
||||
Task<PagedList<BrowsePersonDto>> GetAllWritersAndSeriesCount(int userId, UserParams userParams);
|
||||
Task<Person?> GetPersonById(int personId);
|
||||
Task<PersonDto?> GetPersonDtoByName(string name, int userId);
|
||||
|
@ -145,18 +145,28 @@ public class PersonRepository : IPersonRepository
|
|||
.SingleOrDefaultAsync();
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<PersonRole>> GetRolesForPersonByName(string name, int userId)
|
||||
public async Task<IEnumerable<PersonRole>> GetRolesForPersonByName(int personId, int userId)
|
||||
{
|
||||
// TODO: This will need to check both series and chapters (in cases where komf only updates series)
|
||||
var normalized = name.ToNormalized();
|
||||
var ageRating = await _context.AppUser.GetUserAgeRestriction(userId);
|
||||
|
||||
return await _context.Person
|
||||
.Where(p => p.NormalizedName == normalized)
|
||||
// Query roles from ChapterPeople
|
||||
var chapterRoles = await _context.Person
|
||||
.Where(p => p.Id == personId)
|
||||
.RestrictAgainstAgeRestriction(ageRating)
|
||||
.SelectMany(p => p.ChapterPeople.Select(cp => cp.Role))
|
||||
.Distinct()
|
||||
.ToListAsync();
|
||||
|
||||
// Query roles from SeriesMetadataPeople
|
||||
var seriesRoles = await _context.Person
|
||||
.Where(p => p.Id == personId)
|
||||
.RestrictAgainstAgeRestriction(ageRating)
|
||||
.SelectMany(p => p.SeriesMetadataPeople.Select(smp => smp.Role))
|
||||
.Distinct()
|
||||
.ToListAsync();
|
||||
|
||||
// Combine and return distinct roles
|
||||
return chapterRoles.Union(seriesRoles).Distinct();
|
||||
}
|
||||
|
||||
public async Task<PagedList<BrowsePersonDto>> GetAllWritersAndSeriesCount(int userId, UserParams userParams)
|
||||
|
|
|
@ -1046,8 +1046,6 @@ public class SeriesRepository : ISeriesRepository
|
|||
.Select(u => u.CollapseSeriesRelationships)
|
||||
.SingleOrDefaultAsync();
|
||||
|
||||
|
||||
|
||||
query ??= _context.Series
|
||||
.AsNoTracking();
|
||||
|
||||
|
@ -1064,7 +1062,6 @@ public class SeriesRepository : ISeriesRepository
|
|||
|
||||
query = ApplyWantToReadFilter(filter, query, userId);
|
||||
|
||||
|
||||
query = await ApplyCollectionFilter(filter, query, userId, userRating);
|
||||
|
||||
|
||||
|
@ -1136,6 +1133,7 @@ public class SeriesRepository : ISeriesRepository
|
|||
var seriesIds = _context.AppUser.Where(u => u.Id == userId)
|
||||
.SelectMany(u => u.WantToRead)
|
||||
.Select(s => s.SeriesId);
|
||||
|
||||
if (bool.Parse(wantToReadStmt.Value))
|
||||
{
|
||||
query = query.Where(s => seriesIds.Contains(s.Id));
|
||||
|
@ -1152,6 +1150,7 @@ public class SeriesRepository : ISeriesRepository
|
|||
{
|
||||
var filterIncludeLibs = new List<int>();
|
||||
var filterExcludeLibs = new List<int>();
|
||||
|
||||
if (filter.Statements != null)
|
||||
{
|
||||
foreach (var stmt in filter.Statements.Where(stmt => stmt.Field == FilterField.Libraries))
|
||||
|
@ -1993,17 +1992,25 @@ public class SeriesRepository : ISeriesRepository
|
|||
public async Task<PagedList<SeriesDto>> GetWantToReadForUserV2Async(int userId, UserParams userParams, FilterV2Dto filter)
|
||||
{
|
||||
var libraryIds = await _context.Library.GetUserLibraries(userId).ToListAsync();
|
||||
var query = _context.AppUser
|
||||
var seriesIds = await _context.AppUser
|
||||
.Where(user => user.Id == userId)
|
||||
.SelectMany(u => u.WantToRead)
|
||||
.Where(s => libraryIds.Contains(s.Series.LibraryId))
|
||||
.Select(w => w.Series)
|
||||
.Select(w => w.Series.Id)
|
||||
.Distinct()
|
||||
.ToListAsync();
|
||||
|
||||
var query = await CreateFilteredSearchQueryableV2(userId, filter, QueryContext.None);
|
||||
|
||||
// Apply the Want to Read filtering
|
||||
query = query.Where(s => seriesIds.Contains(s.Id));
|
||||
|
||||
var retSeries = query
|
||||
.ProjectTo<SeriesDto>(_mapper.ConfigurationProvider)
|
||||
.AsSplitQuery()
|
||||
.AsNoTracking();
|
||||
|
||||
var filteredQuery = await CreateFilteredSearchQueryableV2(userId, filter, QueryContext.None, query);
|
||||
|
||||
return await PagedList<SeriesDto>.CreateAsync(filteredQuery.ProjectTo<SeriesDto>(_mapper.ConfigurationProvider), userParams.PageNumber, userParams.PageSize);
|
||||
return await PagedList<SeriesDto>.CreateAsync(retSeries, userParams.PageNumber, userParams.PageSize);
|
||||
}
|
||||
|
||||
public async Task<IList<Series>> GetWantToReadForUserAsync(int userId)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue