using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Managing.Domain.Backtests;

namespace Managing.Infrastructure.Databases.PostgreSql.Entities;

[Table("BundleBacktestRequests")]
public class BundleBacktestRequestEntity
{
    [Key]
    [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
    public int Id { get; set; }

    [Required]
    [MaxLength(255)]
    public string RequestId { get; set; } = string.Empty;

    // Foreign key to User entity
    public int? UserId { get; set; }
    
    // Navigation property to User entity
    public UserEntity? User { get; set; }

    [Required]
    public DateTime CreatedAt { get; set; } = DateTime.UtcNow;

    public DateTime? CompletedAt { get; set; }

    [Required]
    public BundleBacktestRequestStatus Status { get; set; }

    [Required]
    [Column(TypeName = "text")]
    public string BacktestRequestsJson { get; set; } = string.Empty;

    [Required]
    public int TotalBacktests { get; set; }

    [Required]
    public int CompletedBacktests { get; set; }

    [Required]
    public int FailedBacktests { get; set; }

    [Column(TypeName = "text")]
    public string? ErrorMessage { get; set; }

    [Column(TypeName = "text")]
    public string? ProgressInfo { get; set; }

    [MaxLength(500)]
    public string? CurrentBacktest { get; set; }

    public int? EstimatedTimeRemainingSeconds { get; set; }

    [Required]
    [MaxLength(255)]
    public string Name { get; set; } = string.Empty;

    [Required]
    [Column(TypeName = "jsonb")]
    public string ResultsJson { get; set; } = "[]";

    [Required]
    public DateTime UpdatedAt { get; set; } = DateTime.UtcNow;
} 