RED-6310: Refomatted sql query for readability

This commit is contained in:
Viktor Seifert 2023-03-06 18:48:37 +01:00
parent a32d2bbd41
commit 1fb8e0c135

View File

@ -15,11 +15,19 @@ public interface NotificationRepository extends JpaRepository<NotificationEntity
int hasInAppNotificationForUser(String userId, OffsetDateTime since);
@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.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.softDeleted is null and n.userId = :userId order by n.creationDate desc""")
List<NotificationEntity> 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<NotificationEntity> findUnseenNotificationsForUser(String userId);