package space.nstart.pcp.pcp_types_lib.dto.requests.slots

import java.time.LocalDateTime

data class SlotCalculationSummaryDTO(
    val satelliteId: Long = 0,
    val calculated: Boolean = false,
    val slotCount: Long = 0,
    val minTime: LocalDateTime? = null,
    val maxTime: LocalDateTime? = null,
    val minRevolution: Long? = null,
    val maxRevolution: Long? = null,
    val revolutionInterval: Long? = null,
) {
    companion object {
        fun calculated(
            satelliteId: Long,
            slotCount: Long,
            minTime: LocalDateTime?,
            maxTime: LocalDateTime?,
            minRevolution: Long?,
            maxRevolution: Long?,
        ) = SlotCalculationSummaryDTO(
            satelliteId = satelliteId,
            calculated = slotCount > 0,
            slotCount = slotCount,
            minTime = minTime,
            maxTime = maxTime,
            minRevolution = minRevolution,
            maxRevolution = maxRevolution,
            revolutionInterval = if (minRevolution != null && maxRevolution != null) {
                maxRevolution - minRevolution
            } else {
                null
            },
        )
    }
}
