Update agent summary data annotation

This commit is contained in:
2025-10-03 01:56:57 +07:00
parent be1815ea05
commit c02d011982
2 changed files with 14 additions and 4 deletions

View File

@@ -1,10 +1,18 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Microsoft.EntityFrameworkCore;
namespace Managing.Infrastructure.Databases.PostgreSql.Entities;
[Table("AgentSummaries")]
[Index(nameof(AgentName), IsUnique = true)]
[Index(nameof(UserId), IsUnique = true)]
public class AgentSummaryEntity
{
public int Id { get; set; }
public int UserId { get; set; }
public string AgentName { get; set; }
[Key]
[Required] public int Id { get; set; }
[Required] public required int UserId { get; set; }
[Required] [MaxLength(255)] public required string AgentName { get; set; }
public decimal TotalPnL { get; set; }
public decimal TotalROI { get; set; }
public int Wins { get; set; }

View File

@@ -548,11 +548,13 @@ public class ManagingDbContext : DbContext
entity.Property(e => e.ActiveStrategiesCount).IsRequired();
entity.Property(e => e.TotalVolume).HasPrecision(18, 8);
entity.Property(e => e.TotalBalance).HasPrecision(18, 8);
entity.Property(e => e.TotalFees).HasPrecision(18, 8);
entity.Property(e => e.NetPnL).HasPrecision(18, 8);
entity.Property(e => e.BacktestCount).IsRequired();
// Create indexes for common queries
entity.HasIndex(e => e.UserId).IsUnique();
entity.HasIndex(e => e.AgentName);
entity.HasIndex(e => e.AgentName).IsUnique();
entity.HasIndex(e => e.TotalPnL);
// Configure relationship with User