package org.raddatz.familienarchiv.ocr;

import org.raddatz.familienarchiv.ocr.OcrTrainingRun;
import org.raddatz.familienarchiv.ocr.TrainingStatus;
import org.springframework.data.jpa.repository.JpaRepository;

import java.util.List;
import java.util.Optional;
import java.util.UUID;

public interface OcrTrainingRunRepository extends JpaRepository<OcrTrainingRun, UUID> {

    Optional<OcrTrainingRun> findFirstByStatus(TrainingStatus status);

    Optional<OcrTrainingRun> findFirstByStatusOrderByCreatedAtAsc(TrainingStatus status);

    Optional<OcrTrainingRun> findFirstByPersonIdAndStatus(UUID personId, TrainingStatus status);

    boolean existsByPersonIdAndStatus(UUID personId, TrainingStatus status);

    List<OcrTrainingRun> findTop20ByOrderByCreatedAtDesc();

    List<OcrTrainingRun> findByPersonIdIsNullOrderByCreatedAtDesc();

    List<OcrTrainingRun> findByPersonIdOrderByCreatedAtDesc(UUID personId);
}
