mirror of
https://github.com/C9Glax/tranga.git
synced 2025-10-17 10:50:45 +02:00
Actions use enum
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
using API.Schema.ActionsContext;
|
using API.Schema.ActionsContext;
|
||||||
|
using API.Schema.ActionsContext.Actions;
|
||||||
using Asp.Versioning;
|
using Asp.Versioning;
|
||||||
using Microsoft.AspNetCore.Http.HttpResults;
|
using Microsoft.AspNetCore.Http.HttpResults;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
@@ -13,19 +14,14 @@ namespace API.Controllers;
|
|||||||
public class ActionsController(ActionsContext context) : Controller
|
public class ActionsController(ActionsContext context) : Controller
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns the available Action Types (<see cref="ActionRecord.Action"/>) performed by Tranga
|
/// Returns the available Action Types (<see cref="ActionsEnum"/>)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <response code="200">List of performed action-types</response>
|
/// <response code="200">List of action-types</response>
|
||||||
/// <response code="500">Database error</response>
|
|
||||||
[HttpGet("Types")]
|
[HttpGet("Types")]
|
||||||
[ProducesResponseType(Status200OK)]
|
[ProducesResponseType<ActionsEnum[]>(Status200OK, "application/json")]
|
||||||
[ProducesResponseType(Status500InternalServerError)]
|
public Ok<ActionsEnum[]> GetAvailableActions()
|
||||||
public async Task<Results<Ok<List<string>>, InternalServerError>> GetAvailableActions()
|
|
||||||
{
|
{
|
||||||
if (await context.Actions.Select(a => a.Action).Distinct().ToListAsync(HttpContext.RequestAborted) is not
|
return TypedResults.Ok(Enum.GetValues<ActionsEnum>());
|
||||||
{ } actions)
|
|
||||||
return TypedResults.InternalServerError();
|
|
||||||
return TypedResults.Ok(actions);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public sealed record Interval(DateTime Start, DateTime End);
|
public sealed record Interval(DateTime Start, DateTime End);
|
||||||
@@ -35,7 +31,7 @@ public class ActionsController(ActionsContext context) : Controller
|
|||||||
/// <response code="200">List of performed actions</response>
|
/// <response code="200">List of performed actions</response>
|
||||||
/// <response code="500">Database error</response>
|
/// <response code="500">Database error</response>
|
||||||
[HttpPost("Interval")]
|
[HttpPost("Interval")]
|
||||||
[ProducesResponseType(Status200OK)]
|
[ProducesResponseType<List<ActionRecord>>(Status200OK, "application/json")]
|
||||||
[ProducesResponseType(Status500InternalServerError)]
|
[ProducesResponseType(Status500InternalServerError)]
|
||||||
public async Task<Results<Ok<List<ActionRecord>>, InternalServerError>> GetActionsInterval([FromBody]Interval interval)
|
public async Task<Results<Ok<List<ActionRecord>>, InternalServerError>> GetActionsInterval([FromBody]Interval interval)
|
||||||
{
|
{
|
||||||
@@ -46,14 +42,14 @@ public class ActionsController(ActionsContext context) : Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns <see cref="ActionRecord"/> with type <paramref name="Type"/>
|
/// Returns <see cref="ActionRecord"/> with <paramref name="Type"/> <see cref="ActionsEnum"/>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <response code="200">List of performed actions</response>
|
/// <response code="200">List of performed actions</response>
|
||||||
/// <response code="500">Database error</response>
|
/// <response code="500">Database error</response>
|
||||||
[HttpGet("Type/{Type}")]
|
[HttpGet("Type/{Type}")]
|
||||||
[ProducesResponseType(Status200OK)]
|
[ProducesResponseType<List<ActionRecord>>(Status200OK, "application/json")]
|
||||||
[ProducesResponseType(Status500InternalServerError)]
|
[ProducesResponseType(Status500InternalServerError)]
|
||||||
public async Task<Results<Ok<List<ActionRecord>>, InternalServerError>> GetActionsWithType(string Type)
|
public async Task<Results<Ok<List<ActionRecord>>, InternalServerError>> GetActionsWithType(ActionsEnum Type)
|
||||||
{
|
{
|
||||||
if (await context.Actions.Where(a => a.Action == Type)
|
if (await context.Actions.Where(a => a.Action == Type)
|
||||||
.ToListAsync(HttpContext.RequestAborted) is not { } actions)
|
.ToListAsync(HttpContext.RequestAborted) is not { } actions)
|
||||||
|
@@ -12,7 +12,7 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
|||||||
namespace API.Migrations.Actions
|
namespace API.Migrations.Actions
|
||||||
{
|
{
|
||||||
[DbContext(typeof(ActionsContext))]
|
[DbContext(typeof(ActionsContext))]
|
||||||
[Migration("20251016005257_Actions")]
|
[Migration("20251016170924_Actions")]
|
||||||
partial class Actions
|
partial class Actions
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
@@ -31,10 +31,9 @@ namespace API.Migrations.Actions
|
|||||||
.HasMaxLength(64)
|
.HasMaxLength(64)
|
||||||
.HasColumnType("character varying(64)");
|
.HasColumnType("character varying(64)");
|
||||||
|
|
||||||
b.Property<string>("Action")
|
b.Property<int>("Action")
|
||||||
.IsRequired()
|
|
||||||
.HasMaxLength(128)
|
.HasMaxLength(128)
|
||||||
.HasColumnType("character varying(128)");
|
.HasColumnType("integer");
|
||||||
|
|
||||||
b.Property<DateTime>("PerformedAt")
|
b.Property<DateTime>("PerformedAt")
|
||||||
.HasColumnType("timestamp with time zone");
|
.HasColumnType("timestamp with time zone");
|
||||||
@@ -43,7 +42,7 @@ namespace API.Migrations.Actions
|
|||||||
|
|
||||||
b.ToTable("Actions");
|
b.ToTable("Actions");
|
||||||
|
|
||||||
b.HasDiscriminator<string>("Action").HasValue("ActionRecord");
|
b.HasDiscriminator<int>("Action");
|
||||||
|
|
||||||
b.UseTphMappingStrategy();
|
b.UseTphMappingStrategy();
|
||||||
});
|
});
|
||||||
@@ -57,7 +56,7 @@ namespace API.Migrations.Actions
|
|||||||
.HasMaxLength(64)
|
.HasMaxLength(64)
|
||||||
.HasColumnType("character varying(64)");
|
.HasColumnType("character varying(64)");
|
||||||
|
|
||||||
b.HasDiscriminator().HasValue("Chapter.Downloaded");
|
b.HasDiscriminator().HasValue(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("API.Schema.ActionsContext.Actions.ChaptersRetrievedActionRecord", b =>
|
modelBuilder.Entity("API.Schema.ActionsContext.Actions.ChaptersRetrievedActionRecord", b =>
|
||||||
@@ -70,7 +69,7 @@ namespace API.Migrations.Actions
|
|||||||
.HasMaxLength(64)
|
.HasMaxLength(64)
|
||||||
.HasColumnType("character varying(64)");
|
.HasColumnType("character varying(64)");
|
||||||
|
|
||||||
b.HasDiscriminator().HasValue("Manga.ChaptersRetrieved");
|
b.HasDiscriminator().HasValue(2);
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("API.Schema.ActionsContext.Actions.CoverDownloadedActionRecord", b =>
|
modelBuilder.Entity("API.Schema.ActionsContext.Actions.CoverDownloadedActionRecord", b =>
|
||||||
@@ -88,7 +87,7 @@ namespace API.Migrations.Actions
|
|||||||
.HasMaxLength(64)
|
.HasMaxLength(64)
|
||||||
.HasColumnType("character varying(64)");
|
.HasColumnType("character varying(64)");
|
||||||
|
|
||||||
b.HasDiscriminator().HasValue("Manga.CoverDownloaded");
|
b.HasDiscriminator().HasValue(3);
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("API.Schema.ActionsContext.Actions.DataMovedActionRecord", b =>
|
modelBuilder.Entity("API.Schema.ActionsContext.Actions.DataMovedActionRecord", b =>
|
||||||
@@ -105,7 +104,7 @@ namespace API.Migrations.Actions
|
|||||||
.HasMaxLength(2048)
|
.HasMaxLength(2048)
|
||||||
.HasColumnType("character varying(2048)");
|
.HasColumnType("character varying(2048)");
|
||||||
|
|
||||||
b.HasDiscriminator().HasValue("Tranga.DataMoved");
|
b.HasDiscriminator().HasValue(4);
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("API.Schema.ActionsContext.Actions.LibraryMovedActionRecord", b =>
|
modelBuilder.Entity("API.Schema.ActionsContext.Actions.LibraryMovedActionRecord", b =>
|
||||||
@@ -123,7 +122,7 @@ namespace API.Migrations.Actions
|
|||||||
.HasMaxLength(64)
|
.HasMaxLength(64)
|
||||||
.HasColumnType("character varying(64)");
|
.HasColumnType("character varying(64)");
|
||||||
|
|
||||||
b.HasDiscriminator().HasValue("Manga.LibraryMoved");
|
b.HasDiscriminator().HasValue(5);
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("API.Schema.ActionsContext.Actions.MetadataUpdatedActionRecord", b =>
|
modelBuilder.Entity("API.Schema.ActionsContext.Actions.MetadataUpdatedActionRecord", b =>
|
||||||
@@ -141,14 +140,14 @@ namespace API.Migrations.Actions
|
|||||||
.HasMaxLength(1024)
|
.HasMaxLength(1024)
|
||||||
.HasColumnType("character varying(1024)");
|
.HasColumnType("character varying(1024)");
|
||||||
|
|
||||||
b.HasDiscriminator().HasValue("Manga.MetadataUpdated");
|
b.HasDiscriminator().HasValue(6);
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("API.Schema.ActionsContext.Actions.StartupActionRecord", b =>
|
modelBuilder.Entity("API.Schema.ActionsContext.Actions.StartupActionRecord", b =>
|
||||||
{
|
{
|
||||||
b.HasBaseType("API.Schema.ActionsContext.ActionRecord");
|
b.HasBaseType("API.Schema.ActionsContext.ActionRecord");
|
||||||
|
|
||||||
b.HasDiscriminator().HasValue("Tranga.Started");
|
b.HasDiscriminator().HasValue(0);
|
||||||
});
|
});
|
||||||
#pragma warning restore 612, 618
|
#pragma warning restore 612, 618
|
||||||
}
|
}
|
@@ -16,7 +16,7 @@ namespace API.Migrations.Actions
|
|||||||
columns: table => new
|
columns: table => new
|
||||||
{
|
{
|
||||||
Key = table.Column<string>(type: "character varying(64)", maxLength: 64, nullable: false),
|
Key = table.Column<string>(type: "character varying(64)", maxLength: 64, nullable: false),
|
||||||
Action = table.Column<string>(type: "character varying(128)", maxLength: 128, nullable: false),
|
Action = table.Column<int>(type: "integer", maxLength: 128, nullable: false),
|
||||||
PerformedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
|
PerformedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
|
||||||
ChapterId = table.Column<string>(type: "character varying(64)", maxLength: 64, nullable: true),
|
ChapterId = table.Column<string>(type: "character varying(64)", maxLength: 64, nullable: true),
|
||||||
MangaId = table.Column<string>(type: "character varying(64)", maxLength: 64, nullable: true),
|
MangaId = table.Column<string>(type: "character varying(64)", maxLength: 64, nullable: true),
|
@@ -28,10 +28,9 @@ namespace API.Migrations.Actions
|
|||||||
.HasMaxLength(64)
|
.HasMaxLength(64)
|
||||||
.HasColumnType("character varying(64)");
|
.HasColumnType("character varying(64)");
|
||||||
|
|
||||||
b.Property<string>("Action")
|
b.Property<int>("Action")
|
||||||
.IsRequired()
|
|
||||||
.HasMaxLength(128)
|
.HasMaxLength(128)
|
||||||
.HasColumnType("character varying(128)");
|
.HasColumnType("integer");
|
||||||
|
|
||||||
b.Property<DateTime>("PerformedAt")
|
b.Property<DateTime>("PerformedAt")
|
||||||
.HasColumnType("timestamp with time zone");
|
.HasColumnType("timestamp with time zone");
|
||||||
@@ -40,7 +39,7 @@ namespace API.Migrations.Actions
|
|||||||
|
|
||||||
b.ToTable("Actions");
|
b.ToTable("Actions");
|
||||||
|
|
||||||
b.HasDiscriminator<string>("Action").HasValue("ActionRecord");
|
b.HasDiscriminator<int>("Action");
|
||||||
|
|
||||||
b.UseTphMappingStrategy();
|
b.UseTphMappingStrategy();
|
||||||
});
|
});
|
||||||
@@ -54,7 +53,7 @@ namespace API.Migrations.Actions
|
|||||||
.HasMaxLength(64)
|
.HasMaxLength(64)
|
||||||
.HasColumnType("character varying(64)");
|
.HasColumnType("character varying(64)");
|
||||||
|
|
||||||
b.HasDiscriminator().HasValue("Chapter.Downloaded");
|
b.HasDiscriminator().HasValue(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("API.Schema.ActionsContext.Actions.ChaptersRetrievedActionRecord", b =>
|
modelBuilder.Entity("API.Schema.ActionsContext.Actions.ChaptersRetrievedActionRecord", b =>
|
||||||
@@ -67,7 +66,7 @@ namespace API.Migrations.Actions
|
|||||||
.HasMaxLength(64)
|
.HasMaxLength(64)
|
||||||
.HasColumnType("character varying(64)");
|
.HasColumnType("character varying(64)");
|
||||||
|
|
||||||
b.HasDiscriminator().HasValue("Manga.ChaptersRetrieved");
|
b.HasDiscriminator().HasValue(2);
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("API.Schema.ActionsContext.Actions.CoverDownloadedActionRecord", b =>
|
modelBuilder.Entity("API.Schema.ActionsContext.Actions.CoverDownloadedActionRecord", b =>
|
||||||
@@ -85,7 +84,7 @@ namespace API.Migrations.Actions
|
|||||||
.HasMaxLength(64)
|
.HasMaxLength(64)
|
||||||
.HasColumnType("character varying(64)");
|
.HasColumnType("character varying(64)");
|
||||||
|
|
||||||
b.HasDiscriminator().HasValue("Manga.CoverDownloaded");
|
b.HasDiscriminator().HasValue(3);
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("API.Schema.ActionsContext.Actions.DataMovedActionRecord", b =>
|
modelBuilder.Entity("API.Schema.ActionsContext.Actions.DataMovedActionRecord", b =>
|
||||||
@@ -102,7 +101,7 @@ namespace API.Migrations.Actions
|
|||||||
.HasMaxLength(2048)
|
.HasMaxLength(2048)
|
||||||
.HasColumnType("character varying(2048)");
|
.HasColumnType("character varying(2048)");
|
||||||
|
|
||||||
b.HasDiscriminator().HasValue("Tranga.DataMoved");
|
b.HasDiscriminator().HasValue(4);
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("API.Schema.ActionsContext.Actions.LibraryMovedActionRecord", b =>
|
modelBuilder.Entity("API.Schema.ActionsContext.Actions.LibraryMovedActionRecord", b =>
|
||||||
@@ -120,7 +119,7 @@ namespace API.Migrations.Actions
|
|||||||
.HasMaxLength(64)
|
.HasMaxLength(64)
|
||||||
.HasColumnType("character varying(64)");
|
.HasColumnType("character varying(64)");
|
||||||
|
|
||||||
b.HasDiscriminator().HasValue("Manga.LibraryMoved");
|
b.HasDiscriminator().HasValue(5);
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("API.Schema.ActionsContext.Actions.MetadataUpdatedActionRecord", b =>
|
modelBuilder.Entity("API.Schema.ActionsContext.Actions.MetadataUpdatedActionRecord", b =>
|
||||||
@@ -138,14 +137,14 @@ namespace API.Migrations.Actions
|
|||||||
.HasMaxLength(1024)
|
.HasMaxLength(1024)
|
||||||
.HasColumnType("character varying(1024)");
|
.HasColumnType("character varying(1024)");
|
||||||
|
|
||||||
b.HasDiscriminator().HasValue("Manga.MetadataUpdated");
|
b.HasDiscriminator().HasValue(6);
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("API.Schema.ActionsContext.Actions.StartupActionRecord", b =>
|
modelBuilder.Entity("API.Schema.ActionsContext.Actions.StartupActionRecord", b =>
|
||||||
{
|
{
|
||||||
b.HasBaseType("API.Schema.ActionsContext.ActionRecord");
|
b.HasBaseType("API.Schema.ActionsContext.ActionRecord");
|
||||||
|
|
||||||
b.HasDiscriminator().HasValue("Tranga.Started");
|
b.HasDiscriminator().HasValue(0);
|
||||||
});
|
});
|
||||||
#pragma warning restore 612, 618
|
#pragma warning restore 612, 618
|
||||||
}
|
}
|
||||||
|
@@ -1,16 +1,17 @@
|
|||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using API.Schema.ActionsContext.Actions;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
namespace API.Schema.ActionsContext;
|
namespace API.Schema.ActionsContext;
|
||||||
|
|
||||||
[PrimaryKey("Key")]
|
[PrimaryKey("Key")]
|
||||||
public abstract class ActionRecord(string action, DateTime performedAt) : Identifiable
|
public abstract class ActionRecord(ActionsEnum action, DateTime performedAt) : Identifiable
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Constant string that describes the performed Action
|
/// Constant string that describes the performed Action
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[StringLength(128)]
|
[StringLength(128)]
|
||||||
public string Action { get; init; } = action;
|
public ActionsEnum Action { get; init; } = action;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// UTC Time when Action was performed
|
/// UTC Time when Action was performed
|
||||||
|
12
API/Schema/ActionsContext/Actions/ActionsEnum.cs
Normal file
12
API/Schema/ActionsContext/Actions/ActionsEnum.cs
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
namespace API.Schema.ActionsContext.Actions;
|
||||||
|
|
||||||
|
public enum ActionsEnum
|
||||||
|
{
|
||||||
|
Startup = 0,
|
||||||
|
ChapterDownloaded = 1,
|
||||||
|
ChaptersRetrieved = 2,
|
||||||
|
CoverDownloaded = 3,
|
||||||
|
DataMoved = 4,
|
||||||
|
LibraryMoved = 5,
|
||||||
|
MetadataUpdated = 6
|
||||||
|
}
|
@@ -3,15 +3,13 @@ using API.Schema.MangaContext;
|
|||||||
|
|
||||||
namespace API.Schema.ActionsContext.Actions;
|
namespace API.Schema.ActionsContext.Actions;
|
||||||
|
|
||||||
public sealed class ChapterDownloadedActionRecord(string action, DateTime performedAt, string chapterId) : ActionRecord(action, performedAt)
|
public sealed class ChapterDownloadedActionRecord(ActionsEnum action, DateTime performedAt, string chapterId) : ActionRecord(action, performedAt)
|
||||||
{
|
{
|
||||||
public ChapterDownloadedActionRecord(Chapter chapter) : this(ChapterDownloadedAction, DateTime.UtcNow, chapter.Key) { }
|
public ChapterDownloadedActionRecord(Chapter chapter) : this(ActionsEnum.ChapterDownloaded, DateTime.UtcNow, chapter.Key) { }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Chapter that was downloaded
|
/// Chapter that was downloaded
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[StringLength(64)]
|
[StringLength(64)]
|
||||||
public string ChapterId { get; init; } = chapterId;
|
public string ChapterId { get; init; } = chapterId;
|
||||||
|
|
||||||
public const string ChapterDownloadedAction = "Chapter.Downloaded";
|
|
||||||
}
|
}
|
@@ -3,10 +3,10 @@ using API.Schema.MangaContext;
|
|||||||
|
|
||||||
namespace API.Schema.ActionsContext.Actions;
|
namespace API.Schema.ActionsContext.Actions;
|
||||||
|
|
||||||
public sealed class ChaptersRetrievedActionRecord(string action, DateTime performedAt, string mangaId)
|
public sealed class ChaptersRetrievedActionRecord(ActionsEnum action, DateTime performedAt, string mangaId)
|
||||||
: ActionWithMangaRecord(action, performedAt, mangaId)
|
: ActionWithMangaRecord(action, performedAt, mangaId)
|
||||||
{
|
{
|
||||||
public ChaptersRetrievedActionRecord(Manga manga) : this(ChaptersRetrievedAction, DateTime.UtcNow, manga.Key) { }
|
public ChaptersRetrievedActionRecord(Manga manga) : this(ActionsEnum.ChaptersRetrieved, DateTime.UtcNow, manga.Key) { }
|
||||||
|
|
||||||
public const string ChaptersRetrievedAction = "Manga.ChaptersRetrieved";
|
public const string ChaptersRetrievedAction = "Manga.ChaptersRetrieved";
|
||||||
}
|
}
|
@@ -4,16 +4,14 @@ using API.Schema.MangaContext;
|
|||||||
|
|
||||||
namespace API.Schema.ActionsContext.Actions;
|
namespace API.Schema.ActionsContext.Actions;
|
||||||
|
|
||||||
public sealed class CoverDownloadedActionRecord(string action, DateTime performedAt, string mangaId, string filename)
|
public sealed class CoverDownloadedActionRecord(ActionsEnum action, DateTime performedAt, string mangaId, string filename)
|
||||||
: ActionWithMangaRecord(action, performedAt, mangaId)
|
: ActionWithMangaRecord(action, performedAt, mangaId)
|
||||||
{
|
{
|
||||||
public CoverDownloadedActionRecord(Manga manga, string filename) : this(CoverDownloadedAction, DateTime.UtcNow, manga.Key, filename) { }
|
public CoverDownloadedActionRecord(Manga manga, string filename) : this(ActionsEnum.CoverDownloaded, DateTime.UtcNow, manga.Key, filename) { }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Filename on disk
|
/// Filename on disk
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[StringLength(1024)]
|
[StringLength(1024)]
|
||||||
public string Filename { get; init; } = filename;
|
public string Filename { get; init; } = filename;
|
||||||
|
|
||||||
public const string CoverDownloadedAction = "Manga.CoverDownloaded";
|
|
||||||
}
|
}
|
@@ -2,9 +2,9 @@ using System.ComponentModel.DataAnnotations;
|
|||||||
|
|
||||||
namespace API.Schema.ActionsContext.Actions;
|
namespace API.Schema.ActionsContext.Actions;
|
||||||
|
|
||||||
public sealed class DataMovedActionRecord(string action, DateTime performedAt, string from, string to) : ActionRecord(action, performedAt)
|
public sealed class DataMovedActionRecord(ActionsEnum action, DateTime performedAt, string from, string to) : ActionRecord(action, performedAt)
|
||||||
{
|
{
|
||||||
public DataMovedActionRecord(string from, string to) : this(DataMovedAction, DateTime.UtcNow, from, to) { }
|
public DataMovedActionRecord(string from, string to) : this(ActionsEnum.DataMoved, DateTime.UtcNow, from, to) { }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// From path
|
/// From path
|
||||||
@@ -17,6 +17,4 @@ public sealed class DataMovedActionRecord(string action, DateTime performedAt, s
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
[StringLength(2048)]
|
[StringLength(2048)]
|
||||||
public string To { get; init; } = to;
|
public string To { get; init; } = to;
|
||||||
|
|
||||||
public const string DataMovedAction = "Tranga.DataMoved";
|
|
||||||
}
|
}
|
@@ -3,9 +3,9 @@ using API.Schema.MangaContext;
|
|||||||
|
|
||||||
namespace API.Schema.ActionsContext.Actions.Generic;
|
namespace API.Schema.ActionsContext.Actions.Generic;
|
||||||
|
|
||||||
public abstract class ActionWithMangaRecord(string action, DateTime performedAt, string mangaId) : ActionRecord(action, performedAt)
|
public abstract class ActionWithMangaRecord(ActionsEnum action, DateTime performedAt, string mangaId) : ActionRecord(action, performedAt)
|
||||||
{
|
{
|
||||||
protected ActionWithMangaRecord(string action, DateTime performedAt, Manga manga) : this(action, performedAt, manga.Key) { }
|
protected ActionWithMangaRecord(ActionsEnum action, DateTime performedAt, Manga manga) : this(action, performedAt, manga.Key) { }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// <see cref="Schema.MangaContext.Manga"/> for which the cover was downloaded
|
/// <see cref="Schema.MangaContext.Manga"/> for which the cover was downloaded
|
||||||
|
@@ -4,15 +4,13 @@ using API.Schema.MangaContext;
|
|||||||
|
|
||||||
namespace API.Schema.ActionsContext.Actions;
|
namespace API.Schema.ActionsContext.Actions;
|
||||||
|
|
||||||
public sealed class LibraryMovedActionRecord(string action, DateTime performedAt, string mangaId, string fileLibraryId) : ActionWithMangaRecord(action, performedAt, mangaId)
|
public sealed class LibraryMovedActionRecord(ActionsEnum action, DateTime performedAt, string mangaId, string fileLibraryId) : ActionWithMangaRecord(action, performedAt, mangaId)
|
||||||
{
|
{
|
||||||
public LibraryMovedActionRecord(Manga manga, FileLibrary library) : this(LibraryMovedAction, DateTime.UtcNow, manga.Key, library.Key) { }
|
public LibraryMovedActionRecord(Manga manga, FileLibrary library) : this(ActionsEnum.LibraryMoved, DateTime.UtcNow, manga.Key, library.Key) { }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// <see cref="Schema.MangaContext.FileLibrary"/> for which the cover was downloaded
|
/// <see cref="Schema.MangaContext.FileLibrary"/> for which the cover was downloaded
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[StringLength(64)]
|
[StringLength(64)]
|
||||||
public string FileLibraryId { get; init; } = fileLibraryId;
|
public string FileLibraryId { get; init; } = fileLibraryId;
|
||||||
|
|
||||||
public const string LibraryMovedAction = "Manga.LibraryMoved";
|
|
||||||
}
|
}
|
@@ -5,16 +5,14 @@ using API.Schema.MangaContext.MetadataFetchers;
|
|||||||
|
|
||||||
namespace API.Schema.ActionsContext.Actions;
|
namespace API.Schema.ActionsContext.Actions;
|
||||||
|
|
||||||
public sealed class MetadataUpdatedActionRecord(string action, DateTime performedAt, string mangaId, string metadataFetcher)
|
public sealed class MetadataUpdatedActionRecord(ActionsEnum action, DateTime performedAt, string mangaId, string metadataFetcher)
|
||||||
: ActionWithMangaRecord(action, performedAt, mangaId)
|
: ActionWithMangaRecord(action, performedAt, mangaId)
|
||||||
{
|
{
|
||||||
public MetadataUpdatedActionRecord(Manga manga, MetadataFetcher fetcher) : this(MetadataUpdatedAction, DateTime.UtcNow, manga.Key, fetcher.Name) { }
|
public MetadataUpdatedActionRecord(Manga manga, MetadataFetcher fetcher) : this(ActionsEnum.MetadataUpdated, DateTime.UtcNow, manga.Key, fetcher.Name) { }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Filename on disk
|
/// Filename on disk
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[StringLength(1024)]
|
[StringLength(1024)]
|
||||||
public string MetadataFetcher { get; init; } = metadataFetcher;
|
public string MetadataFetcher { get; init; } = metadataFetcher;
|
||||||
|
|
||||||
public const string MetadataUpdatedAction = "Manga.MetadataUpdated";
|
|
||||||
}
|
}
|
@@ -1,8 +1,6 @@
|
|||||||
namespace API.Schema.ActionsContext.Actions;
|
namespace API.Schema.ActionsContext.Actions;
|
||||||
|
|
||||||
public sealed class StartupActionRecord(string action, DateTime performedAt) : ActionRecord(action, performedAt)
|
public sealed class StartupActionRecord(ActionsEnum action, DateTime performedAt) : ActionRecord(action, performedAt)
|
||||||
{
|
{
|
||||||
public StartupActionRecord() : this(StartupAction, DateTime.UtcNow) { }
|
public StartupActionRecord() : this(ActionsEnum.Startup, DateTime.UtcNow) { }
|
||||||
|
|
||||||
public const string StartupAction = "Tranga.Started";
|
|
||||||
}
|
}
|
@@ -11,12 +11,12 @@ public class ActionsContext(DbContextOptions<ActionsContext> options) : TrangaBa
|
|||||||
{
|
{
|
||||||
modelBuilder.Entity<ActionRecord>()
|
modelBuilder.Entity<ActionRecord>()
|
||||||
.HasDiscriminator(a => a.Action)
|
.HasDiscriminator(a => a.Action)
|
||||||
.HasValue<ChapterDownloadedActionRecord>(ChapterDownloadedActionRecord.ChapterDownloadedAction)
|
.HasValue<ChapterDownloadedActionRecord>(ActionsEnum.ChapterDownloaded)
|
||||||
.HasValue<CoverDownloadedActionRecord>(CoverDownloadedActionRecord.CoverDownloadedAction)
|
.HasValue<CoverDownloadedActionRecord>(ActionsEnum.CoverDownloaded)
|
||||||
.HasValue<ChaptersRetrievedActionRecord>(ChaptersRetrievedActionRecord.ChaptersRetrievedAction)
|
.HasValue<ChaptersRetrievedActionRecord>(ActionsEnum.ChaptersRetrieved)
|
||||||
.HasValue<MetadataUpdatedActionRecord>(MetadataUpdatedActionRecord.MetadataUpdatedAction)
|
.HasValue<MetadataUpdatedActionRecord>(ActionsEnum.MetadataUpdated)
|
||||||
.HasValue<DataMovedActionRecord>(DataMovedActionRecord.DataMovedAction)
|
.HasValue<DataMovedActionRecord>(ActionsEnum.DataMoved)
|
||||||
.HasValue<LibraryMovedActionRecord>(LibraryMovedActionRecord.LibraryMovedAction)
|
.HasValue<LibraryMovedActionRecord>(ActionsEnum.LibraryMoved)
|
||||||
.HasValue<StartupActionRecord>(StartupActionRecord.StartupAction);
|
.HasValue<StartupActionRecord>(ActionsEnum.Startup);
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -10,13 +10,20 @@
|
|||||||
"tags": [
|
"tags": [
|
||||||
"Actions"
|
"Actions"
|
||||||
],
|
],
|
||||||
"summary": "Returns the available Action Types (API.Schema.ActionsContext.ActionRecord.Action) performed by Tranga",
|
"summary": "Returns the available Action Types (API.Schema.ActionsContext.Actions.ActionsEnum)",
|
||||||
"responses": {
|
"responses": {
|
||||||
"200": {
|
"200": {
|
||||||
"description": "List of performed action-types"
|
"description": "List of action-types",
|
||||||
},
|
"content": {
|
||||||
"500": {
|
"application/json; x-version=2.0": {
|
||||||
"description": "Database error"
|
"schema": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"$ref": "#/components/schemas/ActionsEnum"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -53,7 +60,17 @@
|
|||||||
},
|
},
|
||||||
"responses": {
|
"responses": {
|
||||||
"200": {
|
"200": {
|
||||||
"description": "List of performed actions"
|
"description": "List of performed actions",
|
||||||
|
"content": {
|
||||||
|
"application/json; x-version=2.0": {
|
||||||
|
"schema": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"$ref": "#/components/schemas/ActionRecord"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"500": {
|
"500": {
|
||||||
"description": "Database error"
|
"description": "Database error"
|
||||||
@@ -66,20 +83,30 @@
|
|||||||
"tags": [
|
"tags": [
|
||||||
"Actions"
|
"Actions"
|
||||||
],
|
],
|
||||||
"summary": "Returns API.Schema.ActionsContext.ActionRecord with type Type",
|
"summary": "Returns API.Schema.ActionsContext.ActionRecord with TypeAPI.Schema.ActionsContext.Actions.ActionsEnum",
|
||||||
"parameters": [
|
"parameters": [
|
||||||
{
|
{
|
||||||
"name": "Type",
|
"name": "Type",
|
||||||
"in": "path",
|
"in": "path",
|
||||||
"required": true,
|
"required": true,
|
||||||
"schema": {
|
"schema": {
|
||||||
"type": "string"
|
"$ref": "#/components/schemas/ActionsEnum"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"responses": {
|
"responses": {
|
||||||
"200": {
|
"200": {
|
||||||
"description": "List of performed actions"
|
"description": "List of performed actions",
|
||||||
|
"content": {
|
||||||
|
"application/json; x-version=2.0": {
|
||||||
|
"schema": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"$ref": "#/components/schemas/ActionRecord"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"500": {
|
"500": {
|
||||||
"description": "Database error"
|
"description": "Database error"
|
||||||
@@ -3160,6 +3187,40 @@
|
|||||||
},
|
},
|
||||||
"components": {
|
"components": {
|
||||||
"schemas": {
|
"schemas": {
|
||||||
|
"ActionRecord": {
|
||||||
|
"required": [
|
||||||
|
"key"
|
||||||
|
],
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"action": {
|
||||||
|
"$ref": "#/components/schemas/ActionsEnum"
|
||||||
|
},
|
||||||
|
"performedAt": {
|
||||||
|
"type": "string",
|
||||||
|
"description": "UTC Time when Action was performed",
|
||||||
|
"format": "date-time"
|
||||||
|
},
|
||||||
|
"key": {
|
||||||
|
"maxLength": 64,
|
||||||
|
"minLength": 16,
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"additionalProperties": false
|
||||||
|
},
|
||||||
|
"ActionsEnum": {
|
||||||
|
"enum": [
|
||||||
|
"Startup",
|
||||||
|
"ChapterDownloaded",
|
||||||
|
"ChaptersRetrieved",
|
||||||
|
"CoverDownloaded",
|
||||||
|
"DataMoved",
|
||||||
|
"LibraryMoved",
|
||||||
|
"MetadataUpdated"
|
||||||
|
],
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
"AltTitle": {
|
"AltTitle": {
|
||||||
"required": [
|
"required": [
|
||||||
"language",
|
"language",
|
||||||
|
Reference in New Issue
Block a user