Collection Rework (#2830)

This commit is contained in:
Joe Milazzo 2024-04-06 12:03:49 -05:00 committed by GitHub
parent 0dacc061f1
commit deaaccb96a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
93 changed files with 5413 additions and 1120 deletions

View file

@ -29,6 +29,10 @@ public class AppUser : IdentityUser<int>, IHasConcurrencyToken
/// </summary>
public ICollection<ReadingList> ReadingLists { get; set; } = null!;
/// <summary>
/// Collections associated with this user
/// </summary>
public ICollection<AppUserCollection> Collections { get; set; } = null!;
/// <summary>
/// A list of Series the user want's to read
/// </summary>
public ICollection<AppUserWantToRead> WantToRead { get; set; } = null!;

View file

@ -0,0 +1,60 @@
using System;
using System.Collections.Generic;
using API.Entities.Enums;
using API.Entities.Interfaces;
using API.Services.Plus;
namespace API.Entities;
/// <summary>
/// Represents a Collection of Series for a given User
/// </summary>
public class AppUserCollection : IEntityDate
{
public int Id { get; set; }
public required string Title { get; set; }
/// <summary>
/// A normalized string used to check if the collection already exists in the DB
/// </summary>
public required string NormalizedTitle { get; set; }
public string? Summary { get; set; }
/// <summary>
/// Reading lists that are promoted are only done by admins
/// </summary>
public bool Promoted { get; set; }
/// <summary>
/// Path to the (managed) image file
/// </summary>
/// <remarks>The file is managed internally to Kavita's APPDIR</remarks>
public string? CoverImage { get; set; }
public bool CoverImageLocked { get; set; }
/// <summary>
/// The highest age rating from all Series within the collection
/// </summary>
public required AgeRating AgeRating { get; set; } = AgeRating.Unknown;
public ICollection<Series> Items { get; set; } = null!;
public DateTime Created { get; set; }
public DateTime LastModified { get; set; }
public DateTime CreatedUtc { get; set; }
public DateTime LastModifiedUtc { get; set; }
// Sync stuff for Kavita+
/// <summary>
/// Last time Kavita Synced the Collection with an upstream source (for non Kavita sourced collections)
/// </summary>
public DateTime LastSyncUtc { get; set; }
/// <summary>
/// Who created/manages the list. Non-Kavita lists are not editable by the user, except to promote
/// </summary>
public ScrobbleProvider Source { get; set; } = ScrobbleProvider.Kavita;
/// <summary>
/// For Non-Kavita sourced collections, the url to sync from
/// </summary>
public string? SourceUrl { get; set; }
// Relationship
public AppUser AppUser { get; set; } = null!;
public int AppUserId { get; set; }
}

View file

@ -9,6 +9,7 @@ namespace API.Entities;
/// <summary>
/// Represents a user entered field that is used as a tagging and grouping mechanism
/// </summary>
[Obsolete("Use AppUserCollection instead")]
[Index(nameof(Id), nameof(Promoted), IsUnique = true)]
public class CollectionTag
{

View file

@ -14,6 +14,7 @@ public class SeriesMetadata : IHasConcurrencyToken
public string Summary { get; set; } = string.Empty;
[Obsolete("Use AppUserCollection instead")]
public ICollection<CollectionTag> CollectionTags { get; set; } = new List<CollectionTag>();
public ICollection<Genre> Genres { get; set; } = new List<Genre>();

View file

@ -3,6 +3,7 @@ using System.Collections.Generic;
using API.Entities.Enums;
using API.Entities.Interfaces;
using API.Entities.Metadata;
using API.Extensions;
namespace API.Entities;
@ -105,6 +106,7 @@ public class Series : IEntityDate, IHasReadTimeEstimate
public ICollection<AppUserRating> Ratings { get; set; } = null!;
public ICollection<AppUserProgress> Progress { get; set; } = null!;
public ICollection<AppUserCollection> Collections { get; set; } = null!;
/// <summary>
/// Relations to other Series, like Sequels, Prequels, etc
@ -114,6 +116,8 @@ public class Series : IEntityDate, IHasReadTimeEstimate
public ICollection<SeriesRelation> RelationOf { get; set; } = null!;
// Relationships
public List<Volume> Volumes { get; set; } = null!;
public Library Library { get; set; } = null!;
@ -131,4 +135,12 @@ public class Series : IEntityDate, IHasReadTimeEstimate
LastChapterAdded = DateTime.Now;
LastChapterAddedUtc = DateTime.UtcNow;
}
public bool MatchesSeriesByName(string nameNormalized, string localizedNameNormalized)
{
return NormalizedName == nameNormalized ||
NormalizedLocalizedName == nameNormalized ||
NormalizedName == localizedNameNormalized ||
NormalizedLocalizedName == localizedNameNormalized;
}
}