Misc Bugfixes (#1378)
* Fixed an issue where sometimes when loading the next page, the pagination area wouldn't be properly setup due to a missed rendering cycle * Refactored BookController to thin it out and refactor some of the functions to apply IOC. Added some split query statements on a few queries. * Added Split Query to many queries * Added a visual indicator for loading state of PDF. Will spruce up css later. * Added back in logic * Fixed flash of white when refreshing browser * Hooked in a loading progress bar for the pdf reader * Close the pdf reader when pressing ESC
This commit is contained in:
parent
3a10b54422
commit
c650436f57
18 changed files with 315 additions and 389 deletions
|
|
@ -59,6 +59,7 @@ public class CollectionTagRepository : ICollectionTagRepository
|
|||
var tagsToDelete = await _context.CollectionTag
|
||||
.Include(c => c.SeriesMetadatas)
|
||||
.Where(c => c.SeriesMetadatas.Count == 0)
|
||||
.AsSplitQuery()
|
||||
.ToListAsync();
|
||||
_context.RemoveRange(tagsToDelete);
|
||||
|
||||
|
|
@ -112,6 +113,7 @@ public class CollectionTagRepository : ICollectionTagRepository
|
|||
return await _context.CollectionTag
|
||||
.Where(c => c.Id == tagId)
|
||||
.Include(c => c.SeriesMetadatas)
|
||||
.AsSplitQuery()
|
||||
.SingleOrDefaultAsync();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -55,6 +55,7 @@ public class GenreRepository : IGenreRepository
|
|||
.Include(p => p.SeriesMetadatas)
|
||||
.Include(p => p.Chapters)
|
||||
.Where(p => p.SeriesMetadatas.Count == 0 && p.Chapters.Count == 0 && p.ExternalTag == removeExternal)
|
||||
.AsSplitQuery()
|
||||
.ToListAsync();
|
||||
|
||||
_context.Genre.RemoveRange(genresWithNoConnections);
|
||||
|
|
@ -67,6 +68,7 @@ public class GenreRepository : IGenreRepository
|
|||
return await _context.Series
|
||||
.Where(s => libraryIds.Contains(s.LibraryId))
|
||||
.SelectMany(s => s.Metadata.Genres)
|
||||
.AsSplitQuery()
|
||||
.Distinct()
|
||||
.OrderBy(p => p.Title)
|
||||
.ProjectTo<GenreTagDto>(_mapper.ConfigurationProvider)
|
||||
|
|
|
|||
|
|
@ -169,6 +169,7 @@ public class LibraryRepository : ILibraryRepository
|
|||
.Include(f => f.Folders)
|
||||
.OrderBy(l => l.Name)
|
||||
.ProjectTo<LibraryDto>(_mapper.ConfigurationProvider)
|
||||
.AsSplitQuery()
|
||||
.AsNoTracking()
|
||||
.ToListAsync();
|
||||
}
|
||||
|
|
@ -200,7 +201,7 @@ public class LibraryRepository : ILibraryRepository
|
|||
query = query.Include(l => l.AppUsers);
|
||||
}
|
||||
|
||||
return query;
|
||||
return query.AsSplitQuery();
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -259,6 +260,7 @@ public class LibraryRepository : ILibraryRepository
|
|||
.Where(library => library.AppUsers.Contains(user))
|
||||
.Include(l => l.Folders)
|
||||
.AsNoTracking()
|
||||
.AsSplitQuery()
|
||||
.ProjectTo<LibraryDto>(_mapper.ConfigurationProvider)
|
||||
.ToListAsync();
|
||||
}
|
||||
|
|
@ -283,6 +285,7 @@ public class LibraryRepository : ILibraryRepository
|
|||
var ret = await _context.Series
|
||||
.Where(s => libraryIds.Contains(s.LibraryId))
|
||||
.Select(s => s.Metadata.Language)
|
||||
.AsSplitQuery()
|
||||
.AsNoTracking()
|
||||
.Distinct()
|
||||
.ToListAsync();
|
||||
|
|
@ -302,6 +305,7 @@ public class LibraryRepository : ILibraryRepository
|
|||
{
|
||||
return _context.Series
|
||||
.Where(s => libraryIds.Contains(s.LibraryId))
|
||||
.AsSplitQuery()
|
||||
.Select(s => s.Metadata.PublicationStatus)
|
||||
.Distinct()
|
||||
.AsEnumerable()
|
||||
|
|
@ -313,5 +317,4 @@ public class LibraryRepository : ILibraryRepository
|
|||
.OrderBy(s => s.Title);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -54,6 +54,7 @@ public class PersonRepository : IPersonRepository
|
|||
.Include(p => p.SeriesMetadatas)
|
||||
.Include(p => p.ChapterMetadatas)
|
||||
.Where(p => p.SeriesMetadatas.Count == 0 && p.ChapterMetadatas.Count == 0)
|
||||
.AsSplitQuery()
|
||||
.ToListAsync();
|
||||
|
||||
_context.Person.RemoveRange(peopleWithNoConnections);
|
||||
|
|
@ -69,6 +70,7 @@ public class PersonRepository : IPersonRepository
|
|||
.Distinct()
|
||||
.OrderBy(p => p.Name)
|
||||
.AsNoTracking()
|
||||
.AsSplitQuery()
|
||||
.ProjectTo<PersonDto>(_mapper.ConfigurationProvider)
|
||||
.ToListAsync();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -96,6 +96,7 @@ public class ReadingListRepository : IReadingListRepository
|
|||
var query = _context.ReadingList
|
||||
.Where(l => l.AppUserId == userId || (includePromoted && l.Promoted ))
|
||||
.Where(l => l.Items.Any(i => i.SeriesId == seriesId))
|
||||
.AsSplitQuery()
|
||||
.OrderBy(l => l.LastModified)
|
||||
.ProjectTo<ReadingListDto>(_mapper.ConfigurationProvider)
|
||||
.AsNoTracking();
|
||||
|
|
@ -108,6 +109,7 @@ public class ReadingListRepository : IReadingListRepository
|
|||
return await _context.ReadingList
|
||||
.Where(r => r.Id == readingListId)
|
||||
.Include(r => r.Items.OrderBy(item => item.Order))
|
||||
.AsSplitQuery()
|
||||
.SingleOrDefaultAsync();
|
||||
}
|
||||
|
||||
|
|
@ -116,6 +118,7 @@ public class ReadingListRepository : IReadingListRepository
|
|||
var userLibraries = _context.Library
|
||||
.Include(l => l.AppUsers)
|
||||
.Where(library => library.AppUsers.Any(user => user.Id == userId))
|
||||
.AsSplitQuery()
|
||||
.AsNoTracking()
|
||||
.Select(library => library.Id)
|
||||
.ToList();
|
||||
|
|
@ -165,6 +168,7 @@ public class ReadingListRepository : IReadingListRepository
|
|||
})
|
||||
.Where(o => userLibraries.Contains(o.LibraryId))
|
||||
.OrderBy(rli => rli.Order)
|
||||
.AsSplitQuery()
|
||||
.AsNoTracking()
|
||||
.ToListAsync();
|
||||
|
||||
|
|
|
|||
|
|
@ -279,6 +279,7 @@ public class SeriesRepository : ISeriesRepository
|
|||
.Include(l => l.AppUsers)
|
||||
.Where(library => library.AppUsers.Any(user => user.Id == userId))
|
||||
.AsNoTracking()
|
||||
.AsSplitQuery()
|
||||
.Select(library => library.Id)
|
||||
.ToListAsync();
|
||||
}
|
||||
|
|
@ -485,6 +486,7 @@ public class SeriesRepository : ISeriesRepository
|
|||
var volumes = await _context.Volume
|
||||
.Where(v => seriesIds.Contains(v.SeriesId))
|
||||
.Include(v => v.Chapters)
|
||||
.AsSplitQuery()
|
||||
.ToListAsync();
|
||||
|
||||
IList<int> chapterIds = new List<int>();
|
||||
|
|
@ -509,6 +511,7 @@ public class SeriesRepository : ISeriesRepository
|
|||
var volumes = await _context.Volume
|
||||
.Where(v => seriesIds.Contains(v.SeriesId))
|
||||
.Include(v => v.Chapters)
|
||||
.AsSplitQuery()
|
||||
.ToListAsync();
|
||||
|
||||
var seriesChapters = new Dictionary<int, IList<int>>();
|
||||
|
|
@ -532,10 +535,12 @@ public class SeriesRepository : ISeriesRepository
|
|||
{
|
||||
var userProgress = await _context.AppUserProgresses
|
||||
.Where(p => p.AppUserId == userId && series.Select(s => s.Id).Contains(p.SeriesId))
|
||||
.AsSplitQuery()
|
||||
.ToListAsync();
|
||||
|
||||
var userRatings = await _context.AppUserRating
|
||||
.Where(r => r.AppUserId == userId && series.Select(s => s.Id).Contains(r.SeriesId))
|
||||
.AsSplitQuery()
|
||||
.ToListAsync();
|
||||
|
||||
foreach (var s in series)
|
||||
|
|
@ -804,6 +809,7 @@ public class SeriesRepository : ISeriesRepository
|
|||
var userLibraries = _context.Library
|
||||
.Include(l => l.AppUsers)
|
||||
.Where(library => library.AppUsers.Any(user => user.Id == userId))
|
||||
.AsSplitQuery()
|
||||
.AsNoTracking()
|
||||
.Select(library => library.Id)
|
||||
.ToList();
|
||||
|
|
@ -829,6 +835,7 @@ public class SeriesRepository : ISeriesRepository
|
|||
.Include(v => v.Chapters)
|
||||
.ThenInclude(c => c.Files)
|
||||
.SelectMany(v => v.Chapters.SelectMany(c => c.Files))
|
||||
.AsSplitQuery()
|
||||
.AsNoTracking()
|
||||
.ToListAsync();
|
||||
}
|
||||
|
|
@ -838,6 +845,7 @@ public class SeriesRepository : ISeriesRepository
|
|||
var allowedLibraries = _context.Library
|
||||
.Include(l => l.AppUsers)
|
||||
.Where(library => library.AppUsers.Any(x => x.Id == userId))
|
||||
.AsSplitQuery()
|
||||
.Select(l => l.Id);
|
||||
|
||||
return await _context.Series
|
||||
|
|
@ -920,6 +928,7 @@ public class SeriesRepository : ISeriesRepository
|
|||
return await _context.SeriesMetadata
|
||||
.Where(sm => seriesIds.Contains(sm.SeriesId))
|
||||
.Include(sm => sm.CollectionTags)
|
||||
.AsSplitQuery()
|
||||
.ToListAsync();
|
||||
}
|
||||
|
||||
|
|
@ -993,6 +1002,7 @@ public class SeriesRepository : ISeriesRepository
|
|||
{
|
||||
return _context.AppUser
|
||||
.Where(u => u.Id == userId)
|
||||
.AsSplitQuery()
|
||||
.SelectMany(l => l.Libraries.Select(lib => lib.Id));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -54,6 +54,7 @@ public class TagRepository : ITagRepository
|
|||
.Include(p => p.SeriesMetadatas)
|
||||
.Include(p => p.Chapters)
|
||||
.Where(p => p.SeriesMetadatas.Count == 0 && p.Chapters.Count == 0 && p.ExternalTag == removeExternal)
|
||||
.AsSplitQuery()
|
||||
.ToListAsync();
|
||||
|
||||
_context.Tag.RemoveRange(tagsWithNoConnections);
|
||||
|
|
@ -66,6 +67,7 @@ public class TagRepository : ITagRepository
|
|||
return await _context.Series
|
||||
.Where(s => libraryIds.Contains(s.LibraryId))
|
||||
.SelectMany(s => s.Metadata.Tags)
|
||||
.AsSplitQuery()
|
||||
.Distinct()
|
||||
.OrderBy(t => t.Title)
|
||||
.AsNoTracking()
|
||||
|
|
|
|||
|
|
@ -205,6 +205,7 @@ public class UserRepository : IUserRepository
|
|||
return await _context.Users
|
||||
.Include(u => u.ReadingLists)
|
||||
.ThenInclude(l => l.Items)
|
||||
.AsSplitQuery()
|
||||
.SingleOrDefaultAsync(x => x.UserName == username);
|
||||
}
|
||||
|
||||
|
|
@ -244,6 +245,7 @@ public class UserRepository : IUserRepository
|
|||
{
|
||||
return await _context.Library
|
||||
.Include(l => l.AppUsers)
|
||||
.AsSplitQuery()
|
||||
.AnyAsync(library => library.AppUsers.Any(user => user.Id == userId));
|
||||
}
|
||||
|
||||
|
|
@ -362,6 +364,7 @@ public class UserRepository : IUserRepository
|
|||
Folders = l.Folders.Select(x => x.Path).ToList()
|
||||
}).ToList()
|
||||
})
|
||||
.AsSplitQuery()
|
||||
.AsNoTracking()
|
||||
.ToListAsync();
|
||||
}
|
||||
|
|
@ -390,6 +393,7 @@ public class UserRepository : IUserRepository
|
|||
Folders = l.Folders.Select(x => x.Path).ToList()
|
||||
}).ToList()
|
||||
})
|
||||
.AsSplitQuery()
|
||||
.AsNoTracking()
|
||||
.ToListAsync();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -62,6 +62,7 @@ public class VolumeRepository : IVolumeRepository
|
|||
.Where(c => volumeId == c.VolumeId)
|
||||
.Include(c => c.Files)
|
||||
.SelectMany(c => c.Files)
|
||||
.AsSplitQuery()
|
||||
.AsNoTracking()
|
||||
.ToListAsync();
|
||||
}
|
||||
|
|
@ -106,7 +107,7 @@ public class VolumeRepository : IVolumeRepository
|
|||
|
||||
if (includeChapters)
|
||||
{
|
||||
query = query.Include(v => v.Chapters);
|
||||
query = query.Include(v => v.Chapters).AsSplitQuery();
|
||||
}
|
||||
return await query.ToListAsync();
|
||||
}
|
||||
|
|
@ -123,6 +124,7 @@ public class VolumeRepository : IVolumeRepository
|
|||
.Where(vol => vol.Id == volumeId)
|
||||
.Include(vol => vol.Chapters)
|
||||
.ThenInclude(c => c.Files)
|
||||
.AsSplitQuery()
|
||||
.ProjectTo<VolumeDto>(_mapper.ConfigurationProvider)
|
||||
.SingleAsync(vol => vol.Id == volumeId);
|
||||
|
||||
|
|
@ -143,6 +145,7 @@ public class VolumeRepository : IVolumeRepository
|
|||
.Where(vol => vol.SeriesId == seriesId)
|
||||
.Include(vol => vol.Chapters)
|
||||
.ThenInclude(c => c.Files)
|
||||
.AsSplitQuery()
|
||||
.OrderBy(vol => vol.Number)
|
||||
.ToListAsync();
|
||||
}
|
||||
|
|
@ -157,6 +160,7 @@ public class VolumeRepository : IVolumeRepository
|
|||
return await _context.Volume
|
||||
.Include(vol => vol.Chapters)
|
||||
.ThenInclude(c => c.Files)
|
||||
.AsSplitQuery()
|
||||
.SingleOrDefaultAsync(vol => vol.Id == volumeId);
|
||||
}
|
||||
|
||||
|
|
@ -220,6 +224,4 @@ public class VolumeRepository : IVolumeRepository
|
|||
v.PagesRead = userProgress.Where(p => p.VolumeId == v.Id).Sum(p => p.PagesRead);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue