package com.pharmacopoeia.repository;

import com.pharmacopoeia.entity.DrugChunk;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

public interface DrugChunkRepository extends JpaRepository<DrugChunk, Long> {
    List<DrugChunk> findByDrugId(String drugId);
    List<DrugChunk> findByDrugIdOrderByChunkIndexAsc(String drugId);

    @Query("SELECT COUNT(c) FROM DrugChunk c WHERE c.vec IS NOT NULL")
    long countWithVector();

    @Query("SELECT COUNT(DISTINCT c.drugId) FROM DrugChunk c WHERE c.vec IS NOT NULL")
    long countDistinctDrugsWithVector();
}
