Fixed a bug where series weren't delete-able

This commit is contained in:
Joseph Milazzo 2025-04-29 13:33:29 -05:00
parent 3a0d33ca13
commit 01f9cea86f
3 changed files with 11 additions and 5 deletions

View file

@ -71,6 +71,7 @@ public sealed class DataContext : IdentityDbContext<AppUser, AppRole, int,
public DbSet<ExternalSeriesMetadata> ExternalSeriesMetadata { get; set; } = null!;
public DbSet<ExternalRecommendation> ExternalRecommendation { get; set; } = null!;
public DbSet<ManualMigrationHistory> ManualMigrationHistory { get; set; } = null!;
[Obsolete]
public DbSet<SeriesBlacklist> SeriesBlacklist { get; set; } = null!;
public DbSet<AppUserCollection> AppUserCollection { get; set; } = null!;
public DbSet<ChapterPeople> ChapterPeople { get; set; } = null!;

View file

@ -563,7 +563,13 @@ public class SeriesRepository : ISeriesRepository
if (!fullSeries) return await query.ToListAsync();
return await query.Include(s => s.Volumes)
return await query
.Include(s => s.Volumes)
.ThenInclude(v => v.Chapters)
.ThenInclude(c => c.ExternalRatings)
.Include(s => s.Volumes)
.ThenInclude(v => v.Chapters)
.ThenInclude(c => c.ExternalReviews)
.Include(s => s.Relations)
.Include(s => s.Metadata)

View file

@ -450,7 +450,7 @@ public class SeriesService : ISeriesService
try
{
var chapterMappings =
await _unitOfWork.SeriesRepository.GetChapterIdWithSeriesIdForSeriesAsync(seriesIds.ToArray());
await _unitOfWork.SeriesRepository.GetChapterIdWithSeriesIdForSeriesAsync([.. seriesIds]);
var allChapterIds = new List<int>();
foreach (var mapping in chapterMappings)
@ -458,9 +458,8 @@ public class SeriesService : ISeriesService
allChapterIds.AddRange(mapping.Value);
}
// NOTE: This isn't getting all the people and whatnot currently
// BUG: This isn't getting all the people and whatnot currently
var series = await _unitOfWork.SeriesRepository.GetSeriesByIdsAsync(seriesIds);
_unitOfWork.SeriesRepository.Remove(series);
var libraryIds = series.Select(s => s.LibraryId);
@ -481,7 +480,7 @@ public class SeriesService : ISeriesService
await _unitOfWork.AppUserProgressRepository.CleanupAbandonedChapters();
await _unitOfWork.CollectionTagRepository.RemoveCollectionsWithoutSeries();
_taskScheduler.CleanupChapters(allChapterIds.ToArray());
_taskScheduler.CleanupChapters([.. allChapterIds]);
return true;
}
catch (Exception ex)