This commit is contained in:
Zeeshaun
2026-04-21 15:57:09 +00:00
parent c52bd0c50c
commit 6b3408a1df
20 changed files with 1136 additions and 330 deletions
+56 -11
View File
@@ -1,5 +1,55 @@
namespace Fragalytics.Web.Models;
public static class DemoStatuses
{
public const string Uploaded = "uploaded";
public const string Queued = "queued";
public const string Processing = "processing";
public const string Parsed = "parsed";
public const string Failed = "failed";
}
public static class ClipJobStatuses
{
public const string Pending = "pending";
public const string Rendering = "rendering";
public const string Rendered = "rendered";
public const string Failed = "failed";
}
public static class EventTypes
{
public const string Kill = "kill";
}
public static class ClipMediaFormats
{
public const string Mp4Extension = ".mp4";
public const string WebMExtension = ".webm";
public const string Mp4ContentType = "video/mp4";
public const string WebMContentType = "video/webm";
public static readonly HashSet<string> AllowedExtensions = new(StringComparer.OrdinalIgnoreCase)
{
Mp4Extension,
WebMExtension
};
public static string InferContentType(string extension)
{
return extension.Equals(WebMExtension, StringComparison.OrdinalIgnoreCase)
? WebMContentType
: Mp4ContentType;
}
public static string GetSuggestedFileExtension(string outputFormat)
{
return outputFormat.Equals("webm", StringComparison.OrdinalIgnoreCase)
? WebMExtension
: Mp4Extension;
}
}
public sealed class AppState
{
public int NextDemoId { get; set; } = 1;
@@ -29,7 +79,7 @@ public sealed class DemoRecord
public string OriginalFileName { get; set; } = string.Empty;
public string StoredPath { get; set; } = string.Empty;
public string ParserBackend { get; set; } = string.Empty;
public string Status { get; set; } = "uploaded";
public string Status { get; set; } = DemoStatuses.Uploaded;
public string? ErrorMessage { get; set; }
public DateTime UploadedAtUtc { get; set; } = DateTime.UtcNow;
public DateTime? ProcessedAtUtc { get; set; }
@@ -76,7 +126,7 @@ public sealed class EventRecord
public int Id { get; set; }
public int MatchId { get; set; }
public int? RoundId { get; set; }
public string EventType { get; set; } = "kill";
public string EventType { get; set; } = EventTypes.Kill;
public int Tick { get; set; }
public double? Second { get; set; }
public int? ActorPlayerId { get; set; }
@@ -117,8 +167,8 @@ public sealed class ClipJobRecord
{
public int Id { get; set; }
public int HighlightId { get; set; }
public string Renderer { get; set; } = "future-renderer";
public string Status { get; set; } = "pending";
public string Renderer { get; set; } = RenderBackendNames.FutureRenderer;
public string Status { get; set; } = ClipJobStatuses.Pending;
public int StartTick { get; set; }
public int EndTick { get; set; }
public Dictionary<string, string> Payload { get; set; } = [];
@@ -191,12 +241,7 @@ public sealed class RenderJobContract
public string GetSuggestedFileExtension()
{
if (string.Equals(OutputFormat, "webm", StringComparison.OrdinalIgnoreCase))
{
return ".webm";
}
return ".mp4";
return ClipMediaFormats.GetSuggestedFileExtension(OutputFormat);
}
private static int ReadInt(IReadOnlyDictionary<string, string> payload, string key)
@@ -216,7 +261,7 @@ public sealed class ClipAssetRecord
public int ClipJobId { get; set; }
public string FileName { get; set; } = string.Empty;
public string StoredPath { get; set; } = string.Empty;
public string ContentType { get; set; } = "video/mp4";
public string ContentType { get; set; } = ClipMediaFormats.Mp4ContentType;
public long FileSizeBytes { get; set; }
public DateTime CreatedAtUtc { get; set; } = DateTime.UtcNow;
}