From 1fb8e0c135402cd0517df069295e4db80a5247b2 Mon Sep 17 00:00:00 2001 From: Viktor Seifert Date: Mon, 6 Mar 2023 18:48:37 +0100 Subject: [PATCH] RED-6310: Refomatted sql query for readability --- .../repository/NotificationRepository.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/service/persistence/repository/NotificationRepository.java b/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/service/persistence/repository/NotificationRepository.java index 3346bbb67..7fea3d1e9 100644 --- a/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/service/persistence/repository/NotificationRepository.java +++ b/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/service/persistence/repository/NotificationRepository.java @@ -15,11 +15,19 @@ public interface NotificationRepository extends JpaRepository findAppNotificationsForUser(String userId); - @Query("select n from NotificationEntity n where " + " (exists (select e from NotificationPreferencesEntity e where e.userId = :userId) and n.notificationType in ( select apn from NotificationPreferencesEntity p join p.inAppNotifications apn where p.userId = :userId and p.inAppNotificationsEnabled = true )) " + " and n.seenDate is null and n.softDeleted is null and n.userId = :userId order by n.creationDate desc ") + @Query(""" + select n from NotificationEntity n where + (exists (select e from NotificationPreferencesEntity e where e.userId = :userId) and n.notificationType in + (select apn from NotificationPreferencesEntity p join p.inAppNotifications apn where p.userId = :userId and p.inAppNotificationsEnabled = true)) + and n.seenDate is null and n.softDeleted is null and n.userId = :userId order by n.creationDate desc""") List findUnseenNotificationsForUser(String userId);