using AsbCloudDb.Model;
using System;
using System.Collections.Generic;
using System.Linq;

namespace AsbCloudInfrastructure.Services.WellOperationService;


class Race
{
    /// <summary>
    /// Дата начала рейса
    /// </summary>
    public DateTime StartDate { get; set; }

    /// <summary>
    /// Глубина начала рейса, м
    /// </summary>
    public double StartWellDepth { get; set; }

    /// <summary>
    /// Дата окончания рейса
    /// </summary>
    public DateTime EndDate { get; set; }

    /// <summary>
    /// Глубина окончания рейса, м
    /// </summary>
    public double EndWellDepth { get; set; }

    /// <summary>
    /// Время рейса, часы
    /// </summary>
    public double DrillingTime { get; set; }

    /// <summary>
    /// Время НПВ, часы
    /// </summary>
    public double NonProductiveHours { get; set; }

    /// <summary>
    /// Ремонт, часы
    /// </summary>
    public double RepairHours { get; set; }

    /// <summary>
    /// проходка за рейс, м
    /// </summary>
    public double DeltaDepth => EndWellDepth - StartWellDepth;

    /// <summary>
    /// Полное время рейса, часы
    /// </summary>
    public double DeltaHours => (EndDate - StartDate).TotalHours;

    /// <summary>
    /// Скорость за рейс, м/час
    /// </summary>
    public double Speed => DeltaDepth / (DeltaHours - NonProductiveHours - RepairHours + double.Epsilon);
    
    /// <summary>
    /// Список операций за рейс
    /// </summary>
    public List<WellOperation> Operations { get; internal set; } = new List<WellOperation>();
}