This commit is contained in:
@@ -50,4 +50,20 @@ public interface TariffInfoRepository extends JpaRepository<TariffInfo, String>
|
||||
ORDER BY user_count DESC
|
||||
""", nativeQuery = true)
|
||||
List<Object[]> getTariffStatisticsNative(@Param("activeOnly") boolean activeOnly);
|
||||
|
||||
@Query("""
|
||||
SELECT COUNT(ti.id)
|
||||
FROM TariffInfo ti
|
||||
WHERE ti.endTariff >= CURRENT_TIMESTAMP
|
||||
AND (:term IS NULL OR ti.tariff.tariffTerm = :term)
|
||||
""")
|
||||
Long getCurrentActiveSubscriptions(@Param("term") String term);
|
||||
|
||||
@Query("""
|
||||
SELECT ti
|
||||
FROM TariffInfo ti
|
||||
WHERE (:term IS NULL OR ti.tariff.tariffTerm = :term)
|
||||
ORDER BY ti.startTariff
|
||||
""")
|
||||
List<TariffInfo> getAllTariffInfosForAnalysis(@Param("term") String term);
|
||||
}
|
||||
|
||||
@@ -3,10 +3,12 @@ package ru.soune.nocopy.repository;
|
||||
import jakarta.validation.constraints.Size;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
import ru.soune.nocopy.entity.tarif.TariffInfo;
|
||||
import ru.soune.nocopy.entity.user.User;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
public interface UserRepository extends JpaRepository<User, Long> {
|
||||
User findByEmail(String email);
|
||||
@@ -40,4 +42,7 @@ public interface UserRepository extends JpaRepository<User, Long> {
|
||||
AND created_at < DATE_TRUNC('month', NOW())
|
||||
""", nativeQuery = true)
|
||||
Long getNewUsersPreviousMonth();
|
||||
|
||||
@Query("SELECT u FROM User u WHERE u.personalTariffInfo.id = :tariffInfoId")
|
||||
Optional<User> findByPersonalTariffInfoId(@Param("tariffInfoId") String tariffInfoId);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user