ComicInfo Derived Reading Lists (#1929)
* Implemented the ability to generate reading lists from StoryArc and StoryArcNumber ComicInfo fields. * Refactored to add AlternativeSeries support. * Fixed up the handling when we need to update reading list where order is already present. * Refactored how skipping empty reading list pairs works
This commit is contained in:
parent
1e535d27fa
commit
7f53eadfda
13 changed files with 2061 additions and 41 deletions
|
|
@ -110,6 +110,9 @@ public sealed class DataContext : IdentityDbContext<AppUser, AppRole, int,
|
|||
builder.Entity<Library>()
|
||||
.Property(b => b.ManageCollections)
|
||||
.HasDefaultValue(true);
|
||||
builder.Entity<Library>()
|
||||
.Property(b => b.ManageReadingLists)
|
||||
.HasDefaultValue(true);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ public class ComicInfo
|
|||
public string SeriesGroup { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// Can contain multiple comma separated numbers that match with StoryArcNumber
|
||||
/// </summary>
|
||||
public string StoryArc { get; set; } = string.Empty;
|
||||
/// <summary>
|
||||
|
|
|
|||
1877
API/Data/Migrations/20230415123449_ManageReadingListOnLibrary.Designer.cs
generated
Normal file
1877
API/Data/Migrations/20230415123449_ManageReadingListOnLibrary.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -0,0 +1,29 @@
|
|||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace API.Data.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class ManageReadingListOnLibrary : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<bool>(
|
||||
name: "ManageReadingLists",
|
||||
table: "Library",
|
||||
type: "INTEGER",
|
||||
nullable: false,
|
||||
defaultValue: true);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "ManageReadingLists",
|
||||
table: "Library");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -15,7 +15,7 @@ namespace API.Data.Migrations
|
|||
protected override void BuildModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder.HasAnnotation("ProductVersion", "7.0.4");
|
||||
modelBuilder.HasAnnotation("ProductVersion", "7.0.5");
|
||||
|
||||
modelBuilder.Entity("API.Entities.AppRole", b =>
|
||||
{
|
||||
|
|
@ -649,6 +649,11 @@ namespace API.Data.Migrations
|
|||
.HasColumnType("INTEGER")
|
||||
.HasDefaultValue(true);
|
||||
|
||||
b.Property<bool>("ManageReadingLists")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER")
|
||||
.HasDefaultValue(true);
|
||||
|
||||
b.Property<string>("Name")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
|
|
|
|||
|
|
@ -48,6 +48,7 @@ public interface IReadingListRepository
|
|||
Task<IList<ReadingList>> GetAllWithNonWebPCovers();
|
||||
Task<IList<string>> GetFirstFourCoverImagesByReadingListId(int readingListId);
|
||||
Task<int> RemoveReadingListsWithoutSeries();
|
||||
Task<ReadingList?> GetReadingListByTitleAsync(string name, int userId, ReadingListIncludes includes = ReadingListIncludes.Items);
|
||||
}
|
||||
|
||||
public class ReadingListRepository : IReadingListRepository
|
||||
|
|
@ -145,6 +146,15 @@ public class ReadingListRepository : IReadingListRepository
|
|||
return await _context.SaveChangesAsync();
|
||||
}
|
||||
|
||||
|
||||
public async Task<ReadingList?> GetReadingListByTitleAsync(string name, int userId, ReadingListIncludes includes = ReadingListIncludes.Items)
|
||||
{
|
||||
var normalized = name.ToNormalized();
|
||||
return await _context.ReadingList
|
||||
.Includes(includes)
|
||||
.FirstOrDefaultAsync(x => x.NormalizedTitle != null && x.NormalizedTitle.Equals(normalized) && x.AppUserId == userId);
|
||||
}
|
||||
|
||||
public void Remove(ReadingListItem item)
|
||||
{
|
||||
_context.ReadingListItem.Remove(item);
|
||||
|
|
|
|||
|
|
@ -62,6 +62,7 @@ public interface IUserRepository
|
|||
Task<bool> HasAccessToLibrary(int libraryId, int userId);
|
||||
Task<IEnumerable<AppUser>> GetAllUsersAsync(AppUserIncludes includeFlags = AppUserIncludes.None);
|
||||
Task<AppUser?> GetUserByConfirmationToken(string token);
|
||||
Task<AppUser> GetDefaultAdminUser();
|
||||
}
|
||||
|
||||
public class UserRepository : IUserRepository
|
||||
|
|
@ -220,6 +221,17 @@ public class UserRepository : IUserRepository
|
|||
.SingleOrDefaultAsync(u => u.ConfirmationToken != null && u.ConfirmationToken.Equals(token));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the first admin account created
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<AppUser> GetDefaultAdminUser()
|
||||
{
|
||||
return (await _userManager.GetUsersInRoleAsync(PolicyConstants.AdminRole))
|
||||
.OrderByDescending(u => u.Created)
|
||||
.First();
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<AppUser>> GetAdminUsersAsync()
|
||||
{
|
||||
return await _userManager.GetUsersInRoleAsync(PolicyConstants.AdminRole);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue