Scanner Performance Improvements (#1774)
* Refactored the Genre code to be faster and used a dictonary to avoid some lookups. May fix the rare foreign constraint issue. * Refactored tag to the same implementation as Genre. Ensure when grabbing tags from ComicInfo, we normalize and throw out duplicates. * Removed an internal "external" field that was planned for Genres and Tags, but now with new plugin architecture, not needed.
This commit is contained in:
parent
48aebfc3c2
commit
8a0a2f0961
18 changed files with 1925 additions and 152 deletions
|
|
@ -14,20 +14,18 @@ public static class GenreHelper
|
|||
/// </summary>
|
||||
/// <param name="allGenres"></param>
|
||||
/// <param name="names"></param>
|
||||
/// <param name="isExternal"></param>
|
||||
/// <param name="action"></param>
|
||||
public static void UpdateGenre(ICollection<Genre> allGenres, IEnumerable<string> names, bool isExternal, Action<Genre> action)
|
||||
public static void UpdateGenre(ICollection<Genre> allGenres, IEnumerable<string> names, Action<Genre> action)
|
||||
{
|
||||
foreach (var name in names)
|
||||
{
|
||||
if (string.IsNullOrEmpty(name.Trim())) continue;
|
||||
|
||||
var normalizedName = Services.Tasks.Scanner.Parser.Parser.Normalize(name);
|
||||
var genre = allGenres.FirstOrDefault(p =>
|
||||
p.NormalizedTitle.Equals(normalizedName) && p.ExternalTag == isExternal);
|
||||
var genre = allGenres.FirstOrDefault(p => p.NormalizedTitle.Equals(normalizedName));
|
||||
if (genre == null)
|
||||
{
|
||||
genre = DbFactory.Genre(name, false);
|
||||
genre = DbFactory.Genre(name);
|
||||
allGenres.Add(genre);
|
||||
}
|
||||
|
||||
|
|
@ -41,7 +39,7 @@ public static class GenreHelper
|
|||
var existing = existingGenres.ToList();
|
||||
foreach (var genre in existing)
|
||||
{
|
||||
var existingPerson = removeAllExcept.FirstOrDefault(g => g.ExternalTag == genre.ExternalTag && genre.NormalizedTitle.Equals(g.NormalizedTitle));
|
||||
var existingPerson = removeAllExcept.FirstOrDefault(g => genre.NormalizedTitle.Equals(g.NormalizedTitle));
|
||||
if (existingPerson != null) continue;
|
||||
existingGenres.Remove(genre);
|
||||
action?.Invoke(genre);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue