mirror of
https://github.com/Kareadita/Kavita.git
synced 2025-05-24 00:52:23 -04:00
* Added a reoccuring task to cleanup db entries that might be abandoned. On library page, the Library in question will be prepoulated. * Laid out the foundation for customized sorting. Added all series page to the UI when clicking on Libraries section header on home page so user can apply any filtering they like. * When filtering, the current library filter will now automatically filter out the options for people and genres. * Implemented Sorting controls * Clear now clears sorting and read progress. Sorting is disabled on deck and recently added. * Fixed an issue where all-series page couldn't click to open series * Don't let the user unselect the last read progress. Added new comicinfo v2.1 draft tags. * Hooked in Translator tag into backend and UI. * Fixed an issue where you could open multiple typeaheads at the same time * Integrated Translator and Tags ComicInfo extension fields. Started work on a badge expander. * Reworked a bit more on badge expander. Added the UI code for Age Rating and Tags * Integrated backend for Tags, Translator, and Age Rating * Metadata tags now collapse if more than 4 present * Some code cleanup * Made the not read badge slightly smaller
80 lines
2.2 KiB
C#
80 lines
2.2 KiB
C#
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
using API.DTOs;
|
|
using API.Entities;
|
|
using AutoMapper;
|
|
using AutoMapper.QueryableExtensions;
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
namespace API.Data.Repositories;
|
|
|
|
public interface IPersonRepository
|
|
{
|
|
void Attach(Person person);
|
|
void Remove(Person person);
|
|
Task<IList<Person>> GetAllPeople();
|
|
Task RemoveAllPeopleNoLongerAssociated(bool removeExternal = false);
|
|
Task<IList<PersonDto>> GetAllPeopleDtosForLibrariesAsync(List<int> libraryIds);
|
|
}
|
|
|
|
public class PersonRepository : IPersonRepository
|
|
{
|
|
private readonly DataContext _context;
|
|
private readonly IMapper _mapper;
|
|
|
|
public PersonRepository(DataContext context, IMapper mapper)
|
|
{
|
|
_context = context;
|
|
_mapper = mapper;
|
|
}
|
|
|
|
public void Attach(Person person)
|
|
{
|
|
_context.Person.Attach(person);
|
|
}
|
|
|
|
public void Remove(Person person)
|
|
{
|
|
_context.Person.Remove(person);
|
|
}
|
|
|
|
public async Task<Person> FindByNameAsync(string name)
|
|
{
|
|
var normalizedName = Parser.Parser.Normalize(name);
|
|
return await _context.Person
|
|
.Where(p => normalizedName.Equals(p.NormalizedName))
|
|
.SingleOrDefaultAsync();
|
|
}
|
|
|
|
public async Task RemoveAllPeopleNoLongerAssociated(bool removeExternal = false)
|
|
{
|
|
var peopleWithNoConnections = await _context.Person
|
|
.Include(p => p.SeriesMetadatas)
|
|
.Include(p => p.ChapterMetadatas)
|
|
.Where(p => p.SeriesMetadatas.Count == 0 && p.ChapterMetadatas.Count == 0)
|
|
.ToListAsync();
|
|
|
|
_context.Person.RemoveRange(peopleWithNoConnections);
|
|
|
|
await _context.SaveChangesAsync();
|
|
}
|
|
|
|
public async Task<IList<PersonDto>> GetAllPeopleDtosForLibrariesAsync(List<int> libraryIds)
|
|
{
|
|
return await _context.Series
|
|
.Where(s => libraryIds.Contains(s.LibraryId))
|
|
.SelectMany(s => s.Metadata.People)
|
|
.Distinct()
|
|
.ProjectTo<PersonDto>(_mapper.ConfigurationProvider)
|
|
.ToListAsync();
|
|
}
|
|
|
|
|
|
public async Task<IList<Person>> GetAllPeople()
|
|
{
|
|
return await _context.Person
|
|
.ToListAsync();
|
|
}
|
|
}
|