package org.brapi.test.BrAPITestServer.repository.geno;

import java.util.Collection;
import java.util.List;

import org.brapi.test.BrAPITestServer.model.entity.geno.CallSetEntity;
import org.brapi.test.BrAPITestServer.repository.BrAPIRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

public interface CallSetRepository extends BrAPIRepository<CallSetEntity, String> {

	@Query("SELECT COUNT(cs) FROM CallSetEntity cs JOIN cs.variantSets vs WHERE vs.id = :variantSetDbId")
	long countByVariantSetDbId(@Param("variantSetDbId") String variantSetDbId);

	@Query("SELECT vs.id, COUNT(cs) FROM CallSetEntity cs JOIN cs.variantSets vs WHERE vs.id IN :variantSetDbIds GROUP BY vs.id")
	List<Object[]> countCallSetsGroupedByVariantSetId(@Param("variantSetDbIds") Collection<String> variantSetDbIds);

}
