package cloud.nstart.terravault.ordinis.domain.webhook;

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

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

public interface WebhookSubscriptionRepository extends JpaRepository<WebhookSubscription, UUID> {

  /**
   * Активные подписки. Использует partial index {@code idx_webhook_subscriptions_active}
   * (where active = true). Hot path в WebhookDispatcher.
   */
  @Query("SELECT w FROM WebhookSubscription w WHERE w.active = true")
  List<WebhookSubscription> findActive();

  /** Метрика {@code nsi_webhook_subscriptions_active}. */
  long countByActiveTrue();
}
