WebUI Redesign and Component 1: category mapper fixes
This commit is contained in:
@@ -1,14 +1,17 @@
|
||||
using Predictalytics.Application.Interfaces;
|
||||
using Predictalytics.Application.Services;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Routing;
|
||||
|
||||
namespace Predictalytics.Api.Endpoints;
|
||||
|
||||
public static class TraderEndpoints
|
||||
{
|
||||
public static void MapTraderEndpoints(this WebApplication app)
|
||||
public static void MapTraderReadEndpoints(this IEndpointRouteBuilder routes)
|
||||
{
|
||||
var group = app.MapGroup("/api/traders").WithTags("Traders");
|
||||
var group = routes.MapGroup("/api/traders").WithTags("Traders");
|
||||
|
||||
group.MapGet("/", async (IAnalyticsService svc, int? skip, int? take, string? platform, bool? highlyCopyable, string? trait, CancellationToken ct) =>
|
||||
Results.Ok(await svc.GetTradersAsync(skip ?? 0, take ?? 50, platform, highlyCopyable ?? false, trait, ct)));
|
||||
@@ -22,48 +25,12 @@ public static class TraderEndpoints
|
||||
return detail is not null ? Results.Ok(detail) : Results.NotFound();
|
||||
});
|
||||
|
||||
group.MapGet("/{id:int}/deep-dive", async (int id, IAnalyticsService svc, CancellationToken ct) =>
|
||||
{
|
||||
var dd = await svc.GetTraderDeepDiveAsync(id, ct);
|
||||
return dd is not null ? Results.Ok(dd) : Results.NotFound();
|
||||
});
|
||||
|
||||
group.MapGet("/{id:int}/positions", async (int id, IAnalyticsService svc, CancellationToken ct) =>
|
||||
{
|
||||
var positions = await svc.GetTraderPositionsAsync(id, ct);
|
||||
return Results.Ok(positions);
|
||||
});
|
||||
|
||||
group.MapPost("/{id:int}/priority", async (int id, int? score, IScoringService svc, CancellationToken ct) =>
|
||||
{
|
||||
await svc.SetManualOverrideAsync(id, score, ct);
|
||||
return Results.Ok();
|
||||
});
|
||||
|
||||
|
||||
group.MapPost("/{id:int}/watchlist", async (int id, WatchlistService svc, CancellationToken ct) =>
|
||||
{
|
||||
await svc.AddAsync(id, "Watched via UI", null, ct);
|
||||
return Results.Ok();
|
||||
});
|
||||
|
||||
group.MapDelete("/{id:int}/watchlist", async (int id, WatchlistService svc, CancellationToken ct) =>
|
||||
{
|
||||
await svc.RemoveByTraderIdAsync(id, ct);
|
||||
return Results.Ok();
|
||||
});
|
||||
|
||||
group.MapPost("/{id:int}/ai-analysis", async (int id, bool manual, IAiStrategyAnalysisService aiSvc, CancellationToken ct) =>
|
||||
{
|
||||
var summary = await aiSvc.AnalyzeTraderStrategyAsync(id, manual, ct);
|
||||
return Results.Ok(new { summary });
|
||||
});
|
||||
|
||||
group.MapPost("/", async (string platform, string wallet, IAnalyticsService svc, CancellationToken ct) =>
|
||||
{
|
||||
var id = await svc.AddTraderAsync(platform, wallet, ct);
|
||||
return Results.Ok(new { id });
|
||||
});
|
||||
group.MapGet("/{id:int}/profile", async (int id, Predictalytics.Infrastructure.Data.AppDbContext db, CancellationToken ct) =>
|
||||
{
|
||||
var trader = await db.Traders.Include(t => t.Analytics).FirstOrDefaultAsync(t => t.Id == id, ct);
|
||||
@@ -128,4 +95,45 @@ public static class TraderEndpoints
|
||||
));
|
||||
});
|
||||
}
|
||||
|
||||
public static void MapTraderControlEndpoints(this IEndpointRouteBuilder routes)
|
||||
{
|
||||
var group = routes.MapGroup("/api/traders").WithTags("Traders");
|
||||
|
||||
group.MapGet("/{id:int}/deep-dive", async (int id, IAnalyticsService svc, CancellationToken ct) =>
|
||||
{
|
||||
var dd = await svc.GetTraderDeepDiveAsync(id, ct);
|
||||
return dd is not null ? Results.Ok(dd) : Results.NotFound();
|
||||
});
|
||||
|
||||
group.MapPost("/{id:int}/priority", async (int id, int? score, IScoringService svc, CancellationToken ct) =>
|
||||
{
|
||||
await svc.SetManualOverrideAsync(id, score, ct);
|
||||
return Results.Ok();
|
||||
});
|
||||
|
||||
group.MapPost("/{id:int}/watchlist", async (int id, WatchlistService svc, CancellationToken ct) =>
|
||||
{
|
||||
await svc.AddAsync(id, "Watched via UI", null, ct);
|
||||
return Results.Ok();
|
||||
});
|
||||
|
||||
group.MapDelete("/{id:int}/watchlist", async (int id, WatchlistService svc, CancellationToken ct) =>
|
||||
{
|
||||
await svc.RemoveByTraderIdAsync(id, ct);
|
||||
return Results.Ok();
|
||||
});
|
||||
|
||||
group.MapPost("/{id:int}/ai-analysis", async (int id, bool manual, IAiStrategyAnalysisService aiSvc, CancellationToken ct) =>
|
||||
{
|
||||
var summary = await aiSvc.AnalyzeTraderStrategyAsync(id, manual, ct);
|
||||
return Results.Ok(new { summary });
|
||||
});
|
||||
|
||||
group.MapPost("/", async (string platform, string wallet, IAnalyticsService svc, CancellationToken ct) =>
|
||||
{
|
||||
var id = await svc.AddTraderAsync(platform, wallet, ct);
|
||||
return Results.Ok(new { id });
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user