mirror of
https://github.com/C9Glax/tranga.git
synced 2025-10-17 10:50:45 +02:00
Fix Actions that can have related chapters and manga
This commit is contained in:
@@ -3,7 +3,9 @@ using API.Schema.MangaContext;
|
||||
|
||||
namespace API.Schema.ActionsContext.Actions;
|
||||
|
||||
public sealed class ChapterDownloadedActionRecord(ActionsEnum action, DateTime performedAt, string chapterId) : ActionWithChapterRecord(action, performedAt, chapterId)
|
||||
public sealed class ChapterDownloadedActionRecord(ActionsEnum action, DateTime performedAt, string mangaId, string chapterId) : ActionRecord(action, performedAt), IActionWithChapterRecord, IActionWithMangaRecord
|
||||
{
|
||||
public ChapterDownloadedActionRecord(Chapter chapter) : this(ActionsEnum.ChapterDownloaded, DateTime.UtcNow, chapter.Key) { }
|
||||
public ChapterDownloadedActionRecord(Manga manga, Chapter chapter) : this(ActionsEnum.ChapterDownloaded, DateTime.UtcNow, manga.Key, chapter.Key) { }
|
||||
public string ChapterId { get; init; } = chapterId;
|
||||
public string MangaId { get; init; } = mangaId;
|
||||
}
|
@@ -4,9 +4,9 @@ using API.Schema.MangaContext;
|
||||
namespace API.Schema.ActionsContext.Actions;
|
||||
|
||||
public sealed class ChaptersRetrievedActionRecord(ActionsEnum action, DateTime performedAt, string mangaId)
|
||||
: ActionWithMangaRecord(action, performedAt, mangaId)
|
||||
: ActionRecord(action, performedAt), IActionWithMangaRecord
|
||||
{
|
||||
public ChaptersRetrievedActionRecord(Manga manga) : this(ActionsEnum.ChaptersRetrieved, DateTime.UtcNow, manga.Key) { }
|
||||
|
||||
public const string ChaptersRetrievedAction = "Manga.ChaptersRetrieved";
|
||||
public string MangaId { get; init; } = mangaId;
|
||||
}
|
@@ -5,7 +5,7 @@ using API.Schema.MangaContext;
|
||||
namespace API.Schema.ActionsContext.Actions;
|
||||
|
||||
public sealed class CoverDownloadedActionRecord(ActionsEnum action, DateTime performedAt, string mangaId, string filename)
|
||||
: ActionWithMangaRecord(action, performedAt, mangaId)
|
||||
: ActionRecord(action, performedAt), IActionWithMangaRecord
|
||||
{
|
||||
public CoverDownloadedActionRecord(Manga manga, string filename) : this(ActionsEnum.CoverDownloaded, DateTime.UtcNow, manga.Key, filename) { }
|
||||
|
||||
@@ -14,4 +14,6 @@ public sealed class CoverDownloadedActionRecord(ActionsEnum action, DateTime per
|
||||
/// </summary>
|
||||
[StringLength(1024)]
|
||||
public string Filename { get; init; } = filename;
|
||||
|
||||
public string MangaId { get; init; } = mangaId;
|
||||
}
|
@@ -1,15 +1,12 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using API.Schema.MangaContext;
|
||||
|
||||
namespace API.Schema.ActionsContext.Actions.Generic;
|
||||
|
||||
public abstract class ActionWithChapterRecord(ActionsEnum action, DateTime performedAt, string chapterId) : ActionRecord(action, performedAt)
|
||||
public interface IActionWithChapterRecord
|
||||
{
|
||||
protected ActionWithChapterRecord(ActionsEnum action, DateTime performedAt, Chapter chapter) : this(action, performedAt, chapter.Key) { }
|
||||
|
||||
/// <summary>
|
||||
/// <see cref="Schema.MangaContext.Manga"/> for which the cover was downloaded
|
||||
/// </summary>
|
||||
[StringLength(64)]
|
||||
public string ChapterId { get; init; } = chapterId;
|
||||
public string ChapterId { get; init; }
|
||||
}
|
@@ -1,15 +1,12 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using API.Schema.MangaContext;
|
||||
|
||||
namespace API.Schema.ActionsContext.Actions.Generic;
|
||||
|
||||
public abstract class ActionWithMangaRecord(ActionsEnum action, DateTime performedAt, string mangaId) : ActionRecord(action, performedAt)
|
||||
public interface IActionWithMangaRecord
|
||||
{
|
||||
protected ActionWithMangaRecord(ActionsEnum action, DateTime performedAt, Manga manga) : this(action, performedAt, manga.Key) { }
|
||||
|
||||
/// <summary>
|
||||
/// <see cref="Schema.MangaContext.Manga"/> for which the cover was downloaded
|
||||
/// </summary>
|
||||
[StringLength(64)]
|
||||
public string MangaId { get; init; } = mangaId;
|
||||
public string MangaId { get; init; }
|
||||
}
|
@@ -4,7 +4,8 @@ using API.Schema.MangaContext;
|
||||
|
||||
namespace API.Schema.ActionsContext.Actions;
|
||||
|
||||
public sealed class LibraryMovedActionRecord(ActionsEnum action, DateTime performedAt, string mangaId, string fileLibraryId) : ActionWithMangaRecord(action, performedAt, mangaId)
|
||||
public sealed class LibraryMovedActionRecord(ActionsEnum action, DateTime performedAt, string mangaId, string fileLibraryId)
|
||||
: ActionRecord(action, performedAt), IActionWithMangaRecord
|
||||
{
|
||||
public LibraryMovedActionRecord(Manga manga, FileLibrary library) : this(ActionsEnum.LibraryMoved, DateTime.UtcNow, manga.Key, library.Key) { }
|
||||
|
||||
@@ -13,4 +14,6 @@ public sealed class LibraryMovedActionRecord(ActionsEnum action, DateTime perfor
|
||||
/// </summary>
|
||||
[StringLength(64)]
|
||||
public string FileLibraryId { get; init; } = fileLibraryId;
|
||||
|
||||
public string MangaId { get; init; } = mangaId;
|
||||
}
|
@@ -6,7 +6,7 @@ using API.Schema.MangaContext.MetadataFetchers;
|
||||
namespace API.Schema.ActionsContext.Actions;
|
||||
|
||||
public sealed class MetadataUpdatedActionRecord(ActionsEnum action, DateTime performedAt, string mangaId, string metadataFetcher)
|
||||
: ActionWithMangaRecord(action, performedAt, mangaId)
|
||||
: ActionRecord(action, performedAt), IActionWithMangaRecord
|
||||
{
|
||||
public MetadataUpdatedActionRecord(Manga manga, MetadataFetcher fetcher) : this(ActionsEnum.MetadataUpdated, DateTime.UtcNow, manga.Key, fetcher.Name) { }
|
||||
|
||||
@@ -15,4 +15,6 @@ public sealed class MetadataUpdatedActionRecord(ActionsEnum action, DateTime per
|
||||
/// </summary>
|
||||
[StringLength(1024)]
|
||||
public string MetadataFetcher { get; init; } = metadataFetcher;
|
||||
|
||||
public string MangaId { get; init; } = mangaId;
|
||||
}
|
@@ -19,5 +19,16 @@ public class ActionsContext(DbContextOptions<ActionsContext> options) : TrangaBa
|
||||
.HasValue<DataMovedActionRecord>(ActionsEnum.DataMoved)
|
||||
.HasValue<LibraryMovedActionRecord>(ActionsEnum.LibraryMoved)
|
||||
.HasValue<StartupActionRecord>(ActionsEnum.Startup);
|
||||
|
||||
modelBuilder.Entity<ChapterDownloadedActionRecord>().Property(a => a.MangaId).HasColumnName("MangaId");
|
||||
modelBuilder.Entity<ChapterDownloadedActionRecord>().Property(a => a.ChapterId).HasColumnName("ChapterId");
|
||||
|
||||
modelBuilder.Entity<CoverDownloadedActionRecord>().Property(a => a.MangaId).HasColumnName("MangaId");
|
||||
|
||||
modelBuilder.Entity<ChaptersRetrievedActionRecord>().Property(a => a.MangaId).HasColumnName("MangaId");
|
||||
|
||||
modelBuilder.Entity<MetadataUpdatedActionRecord>().Property(a => a.MangaId).HasColumnName("MangaId");
|
||||
|
||||
modelBuilder.Entity<LibraryMovedActionRecord>().Property(a => a.MangaId).HasColumnName("MangaId");
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user