.kavitaignore no more (#2442)
This commit is contained in:
parent
cd27efecdd
commit
7221501c4d
91 changed files with 5968 additions and 1026 deletions
|
@ -26,7 +26,8 @@ public enum LibraryIncludes
|
|||
Series = 2,
|
||||
AppUser = 4,
|
||||
Folders = 8,
|
||||
// Ratings = 16
|
||||
FileTypes = 16,
|
||||
ExcludePatterns = 32
|
||||
}
|
||||
|
||||
public interface ILibraryRepository
|
||||
|
@ -86,7 +87,9 @@ public class LibraryRepository : ILibraryRepository
|
|||
{
|
||||
return _context.Library
|
||||
.Include(l => l.AppUsers)
|
||||
.Where(library => library.AppUsers.Any(x => x.UserName.Equals(userName)))
|
||||
.Include(l => l.LibraryFileTypes)
|
||||
.Include(l => l.LibraryExcludePatterns)
|
||||
.Where(library => library.AppUsers.Any(x => x.UserName!.Equals(userName)))
|
||||
.OrderBy(l => l.Name)
|
||||
.ProjectTo<LibraryDto>(_mapper.ConfigurationProvider)
|
||||
.AsSplitQuery()
|
||||
|
@ -100,12 +103,10 @@ public class LibraryRepository : ILibraryRepository
|
|||
/// <returns></returns>
|
||||
public async Task<IEnumerable<Library>> GetLibrariesAsync(LibraryIncludes includes = LibraryIncludes.None)
|
||||
{
|
||||
var query = _context.Library
|
||||
return await _context.Library
|
||||
.Include(l => l.AppUsers)
|
||||
.Select(l => l);
|
||||
|
||||
query = AddIncludesToQuery(query, includes);
|
||||
return await query.ToListAsync();
|
||||
.Includes(includes)
|
||||
.ToListAsync();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -142,11 +143,10 @@ public class LibraryRepository : ILibraryRepository
|
|||
|
||||
public async Task<IEnumerable<Library>> GetLibraryForIdsAsync(IEnumerable<int> libraryIds, LibraryIncludes includes = LibraryIncludes.None)
|
||||
{
|
||||
var query = _context.Library
|
||||
.Where(x => libraryIds.Contains(x.Id));
|
||||
|
||||
AddIncludesToQuery(query, includes);
|
||||
return await query.ToListAsync();
|
||||
return await _context.Library
|
||||
.Where(x => libraryIds.Contains(x.Id))
|
||||
.Includes(includes)
|
||||
.ToListAsync();
|
||||
}
|
||||
|
||||
public async Task<int> GetTotalFiles()
|
||||
|
@ -190,6 +190,7 @@ public class LibraryRepository : ILibraryRepository
|
|||
{
|
||||
return await _context.Library
|
||||
.Include(f => f.Folders)
|
||||
.Include(l => l.LibraryFileTypes)
|
||||
.OrderBy(l => l.Name)
|
||||
.ProjectTo<LibraryDto>(_mapper.ConfigurationProvider)
|
||||
.AsSplitQuery()
|
||||
|
@ -201,31 +202,12 @@ public class LibraryRepository : ILibraryRepository
|
|||
{
|
||||
|
||||
var query = _context.Library
|
||||
.Where(x => x.Id == libraryId);
|
||||
.Where(x => x.Id == libraryId)
|
||||
.Includes(includes);
|
||||
|
||||
query = AddIncludesToQuery(query, includes);
|
||||
return await query.SingleOrDefaultAsync();
|
||||
}
|
||||
|
||||
private static IQueryable<Library> AddIncludesToQuery(IQueryable<Library> query, LibraryIncludes includeFlags)
|
||||
{
|
||||
if (includeFlags.HasFlag(LibraryIncludes.Folders))
|
||||
{
|
||||
query = query.Include(l => l.Folders);
|
||||
}
|
||||
|
||||
if (includeFlags.HasFlag(LibraryIncludes.Series))
|
||||
{
|
||||
query = query.Include(l => l.Series);
|
||||
}
|
||||
|
||||
if (includeFlags.HasFlag(LibraryIncludes.AppUser))
|
||||
{
|
||||
query = query.Include(l => l.AppUsers);
|
||||
}
|
||||
|
||||
return query.AsSplitQuery();
|
||||
}
|
||||
|
||||
public async Task<bool> LibraryExists(string libraryName)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue