feat: Jobs infrastructure, endpoints, UI and worker prioritization

This commit is contained in:
Richard
2026-07-06 19:58:23 +02:00
parent 33a52ed173
commit fb703b6c81
9 changed files with 321 additions and 26 deletions
@@ -20,6 +20,7 @@ public class AppDbContext : DbContext
public DbSet<MarketOutcomePriceSnapshot> MarketOutcomePriceSnapshots => Set<MarketOutcomePriceSnapshot>();
public DbSet<TraderCategoryPerformance> TraderCategoryPerformances => Set<TraderCategoryPerformance>();
public DbSet<TradeContext> TradeContexts => Set<TradeContext>();
public DbSet<BackgroundJob> BackgroundJobs => Set<BackgroundJob>();
public AppDbContext(DbContextOptions<AppDbContext> options) : base(options) { }
@@ -220,5 +221,17 @@ public class AppDbContext : DbContext
e.Property(ps => ps.Price).HasPrecision(10, 6);
e.HasOne(ps => ps.MarketOutcome).WithMany().HasForeignKey(ps => ps.MarketOutcomeId).OnDelete(DeleteBehavior.Cascade);
});
// BackgroundJob
mb.Entity<BackgroundJob>(e =>
{
e.HasKey(j => j.Id);
e.HasIndex(j => j.Status);
e.HasIndex(j => j.JobType);
e.Property(j => j.JobType).HasConversion<string>().HasMaxLength(64);
e.Property(j => j.Status).HasConversion<string>().HasMaxLength(64);
e.Property(j => j.ErrorMessage).HasMaxLength(4096);
e.HasOne(j => j.Trader).WithMany().HasForeignKey(j => j.TraderId).OnDelete(DeleteBehavior.SetNull);
});
}
}
@@ -66,6 +66,7 @@ public static class DependencyInjection
services.AddScoped<IMarketRepository, MarketRepository>();
services.AddScoped<IWatchlistRepository, WatchlistRepository>();
services.AddScoped<IAlertRepository, AlertRepository>();
services.AddScoped<IJobRepository, JobRepository>();
// Application Services
services.AddScoped<IPositionPnLEngine, PositionPnLEngine>();
@@ -67,6 +67,51 @@ namespace Predictalytics.Infrastructure.Migrations
b.ToTable("Alerts");
});
modelBuilder.Entity("Predictalytics.Domain.Entities.BackgroundJob", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property<int>("Id"));
b.Property<DateTime?>("CompletedAt")
.HasColumnType("datetime(6)");
b.Property<DateTime>("CreatedAt")
.HasColumnType("datetime(6)");
b.Property<string>("ErrorMessage")
.HasMaxLength(4096)
.HasColumnType("varchar(4096)");
b.Property<string>("JobType")
.IsRequired()
.HasMaxLength(64)
.HasColumnType("varchar(64)");
b.Property<DateTime?>("StartedAt")
.HasColumnType("datetime(6)");
b.Property<string>("Status")
.IsRequired()
.HasMaxLength(64)
.HasColumnType("varchar(64)");
b.Property<int?>("TraderId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("JobType");
b.HasIndex("Status");
b.HasIndex("TraderId");
b.ToTable("BackgroundJobs");
});
modelBuilder.Entity("Predictalytics.Domain.Entities.Event", b =>
{
b.Property<int>("Id")
@@ -795,6 +840,16 @@ namespace Predictalytics.Infrastructure.Migrations
b.Navigation("Trader");
});
modelBuilder.Entity("Predictalytics.Domain.Entities.BackgroundJob", b =>
{
b.HasOne("Predictalytics.Domain.Entities.Trader", "Trader")
.WithMany()
.HasForeignKey("TraderId")
.OnDelete(DeleteBehavior.SetNull);
b.Navigation("Trader");
});
modelBuilder.Entity("Predictalytics.Domain.Entities.Market", b =>
{
b.HasOne("Predictalytics.Domain.Entities.Event", "Event")