package gc.mda.kcg.domain.aircraft;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.time.Instant;
import java.util.List;

public interface AircraftPositionRepository extends JpaRepository<AircraftPosition, Long> {

    @Query("SELECT a FROM AircraftPosition a WHERE a.region = :region AND a.collectedAt BETWEEN :from AND :to ORDER BY a.collectedAt DESC")
    List<AircraftPosition> findByRegionAndDateRange(
            @Param("region") String region,
            @Param("from") Instant from,
            @Param("to") Instant to);
}
