package gc.mda.kcg.domain.fleet.repository;

import gc.mda.kcg.domain.fleet.CandidateExclusion;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.List;

public interface CandidateExclusionRepository extends JpaRepository<CandidateExclusion, Long> {

    @Query("SELECT e FROM CandidateExclusion e WHERE e.releasedAt IS NULL ORDER BY e.createdAt DESC")
    Page<CandidateExclusion> findActive(Pageable pageable);

    @Query("SELECT e FROM CandidateExclusion e WHERE e.scopeType = :scopeType AND e.releasedAt IS NULL ORDER BY e.createdAt DESC")
    Page<CandidateExclusion> findActiveByScope(@Param("scopeType") String scopeType, Pageable pageable);

    @Query("SELECT e FROM CandidateExclusion e WHERE e.groupKey = :groupKey AND e.releasedAt IS NULL ORDER BY e.createdAt DESC")
    List<CandidateExclusion> findActiveByGroupKey(@Param("groupKey") String groupKey);
}
