package llc.arma.fleet.monitor.data.repository

import llc.arma.fleet.monitor.data.entity.MachineStateIntervalEntity
import org.springframework.data.domain.Page
import org.springframework.data.domain.Pageable
import org.springframework.data.jpa.repository.JpaRepository
import java.time.OffsetDateTime

interface MachineStateIntervalRepository : JpaRepository<MachineStateIntervalEntity, Long> {
    fun findByMachineIdAndStartedAtLessThanEqualAndEndedAtGreaterThanEqual(
        machineId: Long,
        endDate: OffsetDateTime,
        startDate: OffsetDateTime,
    ): List<MachineStateIntervalEntity>

    fun findByMachineIdAndStartedAtBetween(
        machineId: Long,
        startDate: OffsetDateTime,
        endDate: OffsetDateTime,
        pageable: Pageable,
    ): Page<MachineStateIntervalEntity>
}
