Adjust ChapterRating Entity slightly

This commit is contained in:
Amelia 2025-04-26 16:32:13 +02:00
parent 4f3cb6a407
commit f85703eca2
No known key found for this signature in database
GPG key ID: D6D0ECE365407EAA
9 changed files with 25 additions and 18 deletions

View file

@ -87,7 +87,7 @@ public class ReviewController : BaseApiController
.WithChapterId(chapter.Id)
.WithRating(dto.Rating)
.WithReview(dto.Body)
.WithProvider(RatingProvider.Kavita)
.WithProvider(ScrobbleProvider.Kavita)
.Build();
if (rating.Id == 0)

View file

@ -1,4 +1,5 @@
using API.Services.Plus;
using API.Entities;
using API.Services.Plus;
namespace API.DTOs.SeriesDetail;
#nullable enable
@ -56,4 +57,5 @@ public class UserReviewDto
/// If this review is External, which Provider did it come from
/// </summary>
public ScrobbleProvider Provider { get; set; } = ScrobbleProvider.Kavita;
public ReviewAuthority Authority { get; set; } = ReviewAuthority.User;
}

View file

@ -11,8 +11,8 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
namespace API.Data.Migrations
{
[DbContext(typeof(DataContext))]
[Migration("20250425160251_ChapterRatings")]
partial class ChapterRatings
[Migration("20250426142952_ChapterRating")]
partial class ChapterRating
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
@ -207,6 +207,9 @@ namespace API.Data.Migrations
b.Property<int>("AppUserId")
.HasColumnType("INTEGER");
b.Property<int>("Authority")
.HasColumnType("INTEGER");
b.Property<int>("ChapterId")
.HasColumnType("INTEGER");

View file

@ -5,7 +5,7 @@
namespace API.Data.Migrations
{
/// <inheritdoc />
public partial class ChapterRatings : Migration
public partial class ChapterRating : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
@ -20,6 +20,7 @@ namespace API.Data.Migrations
HasBeenRated = table.Column<bool>(type: "INTEGER", nullable: false),
Review = table.Column<string>(type: "TEXT", nullable: true),
Provider = table.Column<int>(type: "INTEGER", nullable: false),
Authority = 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),

View file

@ -204,6 +204,9 @@ namespace API.Data.Migrations
b.Property<int>("AppUserId")
.HasColumnType("INTEGER");
b.Property<int>("Authority")
.HasColumnType("INTEGER");
b.Property<int>("ChapterId")
.HasColumnType("INTEGER");

View file

@ -1,16 +1,24 @@
using API.Entities.Enums;
using API.Services.Plus;
namespace API.Entities;
#nullable enable
public enum ReviewAuthority
{
User = 0,
Critic = 1,
}
public class AppUserChapterRating
{
public int Id { get; set; }
public float Rating { get; set; }
public bool HasBeenRated { get; set; }
public string? Review { get; set; }
public RatingProvider Provider {get; set; }
public ScrobbleProvider Provider { get; set; } = ScrobbleProvider.Kavita;
public ReviewAuthority Authority { get; set; } = ReviewAuthority.User;
public int SeriesId { get; set; }
public Series Series { get; set; } = null!;

View file

@ -1,10 +0,0 @@
namespace API.Entities.Enums;
public enum RatingProvider
{
Kavita = 0,
AniList = 1,
Mal = 2,
CbrUser = 3,
CbrCritic = 4,
}

View file

@ -1,6 +1,7 @@
using System;
using API.Entities;
using API.Entities.Enums;
using API.Services.Plus;
namespace API.Helpers.Builders;
@ -47,7 +48,7 @@ public class ChapterRatingBuilder
return this;
}
public ChapterRatingBuilder WithProvider(RatingProvider provider)
public ChapterRatingBuilder WithProvider(ScrobbleProvider provider)
{
_rating.Provider = provider;
return this;

View file

@ -30,7 +30,6 @@ namespace API.Services.Plus;
/// <summary>
/// Misleading name but is the source of data (like a review coming from AniList)
/// </summary>
/// <remarks>Keep <see cref="RatingProvider"/> in sync</remarks>
public enum ScrobbleProvider
{
/// <summary>