Auto Collection Bugfixes (#1769)
* SeriesGroup tag can now have comma separated value to allow a series to be a part of multiple collections. * Added a missing unit test * Refactored how collection tags are created to work in the scan loop reliably. * Added a unit test for RemoveTagsWithoutSeries * Fixed a bug in reading list title generation to avoid Volume 0 if the underlying file had a title set. Fixed a misconfigured unit test.
This commit is contained in:
parent
e86694ea9a
commit
a76770b240
13 changed files with 234 additions and 106 deletions
|
|
@ -27,7 +27,7 @@ public static class DbFactory
|
|||
NormalizedLocalizedName = Services.Tasks.Scanner.Parser.Parser.Normalize(name),
|
||||
SortName = name,
|
||||
Volumes = new List<Volume>(),
|
||||
Metadata = SeriesMetadata(Array.Empty<CollectionTag>())
|
||||
Metadata = SeriesMetadata(new List<CollectionTag>())
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -46,7 +46,7 @@ public static class DbFactory
|
|||
NormalizedLocalizedName = Services.Tasks.Scanner.Parser.Parser.Normalize(localizedName),
|
||||
SortName = name,
|
||||
Volumes = new List<Volume>(),
|
||||
Metadata = SeriesMetadata(Array.Empty<CollectionTag>())
|
||||
Metadata = SeriesMetadata(new List<CollectionTag>())
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -76,11 +76,6 @@ public static class DbFactory
|
|||
};
|
||||
}
|
||||
|
||||
public static SeriesMetadata SeriesMetadata(ComicInfo info)
|
||||
{
|
||||
return SeriesMetadata(Array.Empty<CollectionTag>());
|
||||
}
|
||||
|
||||
public static SeriesMetadata SeriesMetadata(ICollection<CollectionTag> collectionTags)
|
||||
{
|
||||
return new SeriesMetadata()
|
||||
|
|
@ -98,7 +93,8 @@ public static class DbFactory
|
|||
NormalizedTitle = Services.Tasks.Scanner.Parser.Parser.Normalize(title?.Trim()),
|
||||
Title = title?.Trim(),
|
||||
Summary = summary?.Trim(),
|
||||
Promoted = promoted
|
||||
Promoted = promoted,
|
||||
SeriesMetadatas = new List<SeriesMetadata>()
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ public interface ICollectionTagRepository
|
|||
Task<CollectionTag> GetFullTagAsync(int tagId, CollectionTagIncludes includes = CollectionTagIncludes.SeriesMetadata);
|
||||
void Update(CollectionTag tag);
|
||||
Task<int> RemoveTagsWithoutSeries();
|
||||
Task<IEnumerable<CollectionTag>> GetAllTagsAsync();
|
||||
Task<IEnumerable<CollectionTag>> GetAllTagsAsync(CollectionTagIncludes includes = CollectionTagIncludes.None);
|
||||
Task<IList<string>> GetAllCoverImagesAsync();
|
||||
Task<bool> TagExists(string title);
|
||||
}
|
||||
|
|
@ -66,7 +66,6 @@ public class CollectionTagRepository : ICollectionTagRepository
|
|||
/// </summary>
|
||||
public async Task<int> RemoveTagsWithoutSeries()
|
||||
{
|
||||
// TODO: Write a Unit test to validate this works
|
||||
var tagsToDelete = await _context.CollectionTag
|
||||
.Include(c => c.SeriesMetadatas)
|
||||
.Where(c => c.SeriesMetadatas.Count == 0)
|
||||
|
|
@ -77,10 +76,11 @@ public class CollectionTagRepository : ICollectionTagRepository
|
|||
return await _context.SaveChangesAsync();
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<CollectionTag>> GetAllTagsAsync()
|
||||
public async Task<IEnumerable<CollectionTag>> GetAllTagsAsync(CollectionTagIncludes includes = CollectionTagIncludes.None)
|
||||
{
|
||||
return await _context.CollectionTag
|
||||
.OrderBy(c => c.NormalizedTitle)
|
||||
.Includes(includes)
|
||||
.ToListAsync();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ using API.DTOs.ReadingLists;
|
|||
using API.Entities;
|
||||
using API.Entities.Enums;
|
||||
using API.Helpers;
|
||||
using API.Services;
|
||||
using AutoMapper;
|
||||
using AutoMapper.QueryableExtensions;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
|
@ -145,7 +146,7 @@ public class ReadingListRepository : IReadingListRepository
|
|||
{
|
||||
TotalPages = chapter.Pages,
|
||||
ChapterNumber = chapter.Range,
|
||||
ReleaseDate = chapter.ReleaseDate,
|
||||
chapter.ReleaseDate,
|
||||
ReadingListItem = data,
|
||||
ChapterTitleName = chapter.TitleName,
|
||||
|
||||
|
|
@ -201,7 +202,7 @@ public class ReadingListRepository : IReadingListRepository
|
|||
|
||||
foreach (var item in items)
|
||||
{
|
||||
item.Title = ReadingListHelper.FormatTitle(item);
|
||||
item.Title = ReadingListService.FormatTitle(item);
|
||||
}
|
||||
|
||||
// Attach progress information
|
||||
|
|
|
|||
|
|
@ -199,6 +199,9 @@ public class SeriesRepository : ISeriesRepository
|
|||
var query = _context.Series
|
||||
.Where(s => s.LibraryId == libraryId)
|
||||
|
||||
.Include(s => s.Metadata)
|
||||
.ThenInclude(m => m.CollectionTags)
|
||||
|
||||
.Include(s => s.Metadata)
|
||||
.ThenInclude(m => m.People)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue