package de.oaa.xxx.dating;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

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

public interface DatingDateRepository extends JpaRepository<DatingDateEntity, UUID> {

    List<DatingDateEntity> findByCreatorIdOrderByCreatedAtDesc(UUID creatorId);

    long countByCreatorId(UUID creatorId);

    @Query("SELECT d FROM DatingDateEntity d WHERE d.creatorId != :excludeId AND d.expiresAt > :now ORDER BY d.createdAt DESC")
    List<DatingDateEntity> findAvailableExcluding(@Param("excludeId") UUID excludeId,
                                                   @Param("now") LocalDateTime now);

    List<DatingDateEntity> findAllByExpiresAtBefore(LocalDateTime now);
}
