package at.procon.ted.repository;

import at.procon.ted.model.entity.ProcessingLog;
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 org.springframework.stereotype.Repository;

import java.time.OffsetDateTime;
import java.util.List;
import java.util.UUID;

/**
 * Repository for ProcessingLog entities.
 * 
 * @author Martin.Schweitzer@procon.co.at and claude.ai
 */
@Repository
public interface ProcessingLogRepository extends JpaRepository<ProcessingLog, UUID> {
    
    List<ProcessingLog> findByDocumentIdOrderByCreatedAtDesc(UUID documentId);
    
    List<ProcessingLog> findByDocumentHashOrderByCreatedAtDesc(String documentHash);
    
    Page<ProcessingLog> findByEventTypeOrderByCreatedAtDesc(String eventType, Pageable pageable);
    
    @Query("SELECT l FROM ProcessingLog l WHERE l.createdAt >= :since ORDER BY l.createdAt DESC")
    List<ProcessingLog> findRecentLogs(@Param("since") OffsetDateTime since);
}
