diff --git a/src/Predictalytics.Api/Endpoints/JobEndpoints.cs b/src/Predictalytics.Api/Endpoints/JobEndpoints.cs new file mode 100644 index 0000000..e3fe720 --- /dev/null +++ b/src/Predictalytics.Api/Endpoints/JobEndpoints.cs @@ -0,0 +1,57 @@ +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Routing; +using Predictalytics.Domain.Entities; +using Predictalytics.Domain.Enums; +using Predictalytics.Domain.Interfaces; + +namespace Predictalytics.Api.Endpoints; + +public static class JobEndpoints +{ + public static void MapJobEndpoints(this IEndpointRouteBuilder routes) + { + var group = routes.MapGroup("/api/jobs"); + + group.MapGet("/", async (IJobRepository repo, int skip = 0, int take = 50, CancellationToken ct = default) => + { + var jobs = await repo.GetAllAsync(skip, take, ct); + return Results.Ok(jobs.Select(j => new + { + j.Id, + JobType = j.JobType.ToString(), + Status = j.Status.ToString(), + j.TraderId, + TraderName = j.Trader?.DisplayName ?? j.Trader?.PlatformUserId, + j.CreatedAt, + j.StartedAt, + j.CompletedAt, + j.ErrorMessage + })); + }); + + group.MapPost("/sync/{traderId:int}", async (int traderId, IJobRepository repo, CancellationToken ct) => + { + var job = new BackgroundJob + { + JobType = JobType.HistorySync, + Status = JobStatus.Pending, + TraderId = traderId + }; + await repo.AddAsync(job, ct); + return Results.Ok(job.Id); + }); + + group.MapPost("/analyze/{traderId:int}", async (int traderId, IJobRepository repo, CancellationToken ct) => + { + var job = new BackgroundJob + { + JobType = JobType.TraderAnalysis, + Status = JobStatus.Pending, + TraderId = traderId + }; + await repo.AddAsync(job, ct); + return Results.Ok(job.Id); + }); + } +} diff --git a/src/Predictalytics.Api/wwwroot/css/style.css b/src/Predictalytics.Api/wwwroot/css/style.css index c4cbad4..0b145c1 100644 --- a/src/Predictalytics.Api/wwwroot/css/style.css +++ b/src/Predictalytics.Api/wwwroot/css/style.css @@ -462,8 +462,8 @@ body { .btn-tab:hover { background: var(--bg-input); color: var(--text-primary); } .btn-tab.active { background: var(--bg-input); - color: var(--primary) !important; - border-bottom: 2px solid var(--primary) !important; + color: var(--accent) !important; + border-bottom: 2px solid var(--accent) !important; border-radius: 6px 6px 0 0; } .stat-group { margin-bottom: 16px; } diff --git a/src/Predictalytics.Api/wwwroot/index.html b/src/Predictalytics.Api/wwwroot/index.html index 8a318be..a20bddc 100644 --- a/src/Predictalytics.Api/wwwroot/index.html +++ b/src/Predictalytics.Api/wwwroot/index.html @@ -142,17 +142,15 @@ - - - +
+ Win Rate > + +
+ +
+ Copyability > + +