Add Entity & Migration for ChapterRatings
This commit is contained in:
parent
5c06e14a73
commit
a152f16cf6
7 changed files with 3721 additions and 0 deletions
3515
API/Data/Migrations/20250425160251_ChapterRatings.Designer.cs
generated
Normal file
3515
API/Data/Migrations/20250425160251_ChapterRatings.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load diff
85
API/Data/Migrations/20250425160251_ChapterRatings.cs
Normal file
85
API/Data/Migrations/20250425160251_ChapterRatings.cs
Normal file
|
|
@ -0,0 +1,85 @@
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace API.Data.Migrations
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class ChapterRatings : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "AppUserChapterRating",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<int>(type: "INTEGER", nullable: false)
|
||||||
|
.Annotation("Sqlite:Autoincrement", true),
|
||||||
|
Rating = table.Column<float>(type: "REAL", nullable: false),
|
||||||
|
HasBeenRated = table.Column<bool>(type: "INTEGER", nullable: false),
|
||||||
|
Review = table.Column<string>(type: "TEXT", nullable: true),
|
||||||
|
Provider = table.Column<int>(type: "INTEGER", nullable: false),
|
||||||
|
SeriesId = table.Column<int>(type: "INTEGER", nullable: false),
|
||||||
|
ChapterId = table.Column<int>(type: "INTEGER", nullable: false),
|
||||||
|
VolumeId = table.Column<int>(type: "INTEGER", nullable: false),
|
||||||
|
AppUserId = table.Column<int>(type: "INTEGER", nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_AppUserChapterRating", x => x.Id);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_AppUserChapterRating_AspNetUsers_AppUserId",
|
||||||
|
column: x => x.AppUserId,
|
||||||
|
principalTable: "AspNetUsers",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_AppUserChapterRating_Chapter_ChapterId",
|
||||||
|
column: x => x.ChapterId,
|
||||||
|
principalTable: "Chapter",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_AppUserChapterRating_Series_SeriesId",
|
||||||
|
column: x => x.SeriesId,
|
||||||
|
principalTable: "Series",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_AppUserChapterRating_Volume_VolumeId",
|
||||||
|
column: x => x.VolumeId,
|
||||||
|
principalTable: "Volume",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_AppUserChapterRating_AppUserId",
|
||||||
|
table: "AppUserChapterRating",
|
||||||
|
column: "AppUserId");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_AppUserChapterRating_ChapterId",
|
||||||
|
table: "AppUserChapterRating",
|
||||||
|
column: "ChapterId");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_AppUserChapterRating_SeriesId",
|
||||||
|
table: "AppUserChapterRating",
|
||||||
|
column: "SeriesId");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_AppUserChapterRating_VolumeId",
|
||||||
|
table: "AppUserChapterRating",
|
||||||
|
column: "VolumeId");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "AppUserChapterRating");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -195,6 +195,49 @@ namespace API.Data.Migrations
|
||||||
b.ToTable("AppUserBookmark");
|
b.ToTable("AppUserBookmark");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("API.Entities.AppUserChapterRating", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<int>("AppUserId")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<int>("ChapterId")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<bool>("HasBeenRated")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<int>("Provider")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<float>("Rating")
|
||||||
|
.HasColumnType("REAL");
|
||||||
|
|
||||||
|
b.Property<string>("Review")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<int>("SeriesId")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<int>("VolumeId")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("AppUserId");
|
||||||
|
|
||||||
|
b.HasIndex("ChapterId");
|
||||||
|
|
||||||
|
b.HasIndex("SeriesId");
|
||||||
|
|
||||||
|
b.HasIndex("VolumeId");
|
||||||
|
|
||||||
|
b.ToTable("AppUserChapterRating");
|
||||||
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("API.Entities.AppUserCollection", b =>
|
modelBuilder.Entity("API.Entities.AppUserCollection", b =>
|
||||||
{
|
{
|
||||||
b.Property<int>("Id")
|
b.Property<int>("Id")
|
||||||
|
|
@ -2618,6 +2661,41 @@ namespace API.Data.Migrations
|
||||||
b.Navigation("AppUser");
|
b.Navigation("AppUser");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("API.Entities.AppUserChapterRating", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("API.Entities.AppUser", "AppUser")
|
||||||
|
.WithMany("ChapterRatings")
|
||||||
|
.HasForeignKey("AppUserId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("API.Entities.Chapter", "Chapter")
|
||||||
|
.WithMany("Ratings")
|
||||||
|
.HasForeignKey("ChapterId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("API.Entities.Series", "Series")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("SeriesId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("API.Entities.Volume", "Volume")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("VolumeId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("AppUser");
|
||||||
|
|
||||||
|
b.Navigation("Chapter");
|
||||||
|
|
||||||
|
b.Navigation("Series");
|
||||||
|
|
||||||
|
b.Navigation("Volume");
|
||||||
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("API.Entities.AppUserCollection", b =>
|
modelBuilder.Entity("API.Entities.AppUserCollection", b =>
|
||||||
{
|
{
|
||||||
b.HasOne("API.Entities.AppUser", "AppUser")
|
b.HasOne("API.Entities.AppUser", "AppUser")
|
||||||
|
|
@ -3332,6 +3410,8 @@ namespace API.Data.Migrations
|
||||||
{
|
{
|
||||||
b.Navigation("Bookmarks");
|
b.Navigation("Bookmarks");
|
||||||
|
|
||||||
|
b.Navigation("ChapterRatings");
|
||||||
|
|
||||||
b.Navigation("Collections");
|
b.Navigation("Collections");
|
||||||
|
|
||||||
b.Navigation("DashboardStreams");
|
b.Navigation("DashboardStreams");
|
||||||
|
|
@ -3367,6 +3447,8 @@ namespace API.Data.Migrations
|
||||||
|
|
||||||
b.Navigation("People");
|
b.Navigation("People");
|
||||||
|
|
||||||
|
b.Navigation("Ratings");
|
||||||
|
|
||||||
b.Navigation("UserProgress");
|
b.Navigation("UserProgress");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@ public class AppUser : IdentityUser<int>, IHasConcurrencyToken
|
||||||
public ICollection<AppUserRole> UserRoles { get; set; } = null!;
|
public ICollection<AppUserRole> UserRoles { get; set; } = null!;
|
||||||
public ICollection<AppUserProgress> Progresses { get; set; } = null!;
|
public ICollection<AppUserProgress> Progresses { get; set; } = null!;
|
||||||
public ICollection<AppUserRating> Ratings { get; set; } = null!;
|
public ICollection<AppUserRating> Ratings { get; set; } = null!;
|
||||||
|
public ICollection<AppUserChapterRating> ChapterRatings { get; set; } = null!;
|
||||||
public AppUserPreferences UserPreferences { get; set; } = null!;
|
public AppUserPreferences UserPreferences { get; set; } = null!;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Bookmarks associated with this User
|
/// Bookmarks associated with this User
|
||||||
|
|
|
||||||
36
API/Entities/AppUserChapterRating.cs
Normal file
36
API/Entities/AppUserChapterRating.cs
Normal file
|
|
@ -0,0 +1,36 @@
|
||||||
|
using API.Services.Plus;
|
||||||
|
|
||||||
|
namespace API.Entities;
|
||||||
|
|
||||||
|
#nullable enable
|
||||||
|
|
||||||
|
public enum ChapterRatingProvider
|
||||||
|
{
|
||||||
|
Kavita = 0,
|
||||||
|
AniList = 1,
|
||||||
|
Mal = 2,
|
||||||
|
CbrUser = 3,
|
||||||
|
CbrCritic = 4,
|
||||||
|
}
|
||||||
|
|
||||||
|
public class AppUserChapterRating
|
||||||
|
{
|
||||||
|
|
||||||
|
public int Id { get; set; }
|
||||||
|
public float Rating { get; set; }
|
||||||
|
public bool HasBeenRated { get; set; }
|
||||||
|
public string? Review { get; set; }
|
||||||
|
public ChapterRatingProvider Provider {get; set; }
|
||||||
|
|
||||||
|
public int SeriesId { get; set; }
|
||||||
|
public Series Series { get; set; } = null!;
|
||||||
|
|
||||||
|
public int ChapterId { get; set; }
|
||||||
|
public Chapter Chapter { get; set; } = null!;
|
||||||
|
|
||||||
|
public int VolumeId { get; set; }
|
||||||
|
public Volume Volume { get; set; } = null!;
|
||||||
|
|
||||||
|
public int AppUserId { get; set; }
|
||||||
|
public AppUser AppUser { get; set; } = null!;
|
||||||
|
}
|
||||||
|
|
@ -160,6 +160,7 @@ public class Chapter : IEntityDate, IHasReadTimeEstimate, IHasCoverImage
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public ICollection<Genre> Genres { get; set; } = new List<Genre>();
|
public ICollection<Genre> Genres { get; set; } = new List<Genre>();
|
||||||
public ICollection<Tag> Tags { get; set; } = new List<Tag>();
|
public ICollection<Tag> Tags { get; set; } = new List<Tag>();
|
||||||
|
public ICollection<AppUserChapterRating> Ratings { get; set; } = [];
|
||||||
|
|
||||||
public ICollection<AppUserProgress> UserProgress { get; set; }
|
public ICollection<AppUserProgress> UserProgress { get; set; }
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,7 @@ namespace API.Services.Plus;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Misleading name but is the source of data (like a review coming from AniList)
|
/// Misleading name but is the source of data (like a review coming from AniList)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
/// <remarks>Keep <see cref="ChapterRatingProvider"/> in sync</remarks>
|
||||||
public enum ScrobbleProvider
|
public enum ScrobbleProvider
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue