Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,18 @@ select case when count(nm) > 0 then true else false end
""")
void markUnreadNotificationsAsRead(@Param("appUserId") Long appUserId);

// 1. Method for fetching ALL notifications (No read status filter)
@Query(value = """
select new org.apache.fineract.notification.data.NotificationData(
n.id, n.objectType, n.objectIdentifier, n.actorId, n.action,
n.notificationContent, n.isSystemGenerated, nm.createdAt
nm.notification.id,
nm.notification.objectType,
nm.notification.objectIdentifier,
nm.notification.actorId,
nm.notification.action,
nm.notification.notificationContent,
nm.notification.isSystemGenerated,
nm.createdAt
)
from NotificationMapper nm
join nm.notification n
where nm.userId.id = :appUserId
""", countQuery = """
select count(nm)
Expand All @@ -63,22 +67,25 @@ select count(nm)
""")
Page<NotificationData> findNotificationDataByUserId(@Param("appUserId") Long appUserId, Pageable pageable);

// 2. Method for fetching with a SPECIFIC read status (e.g., Unread only)
@Query(value = """
select new org.apache.fineract.notification.data.NotificationData(
n.id, n.objectType, n.objectIdentifier, n.actorId, n.action,
n.notificationContent, n.isSystemGenerated, nm.createdAt
nm.notification.id,
nm.notification.objectType,
nm.notification.objectIdentifier,
nm.notification.actorId,
nm.notification.action,
nm.notification.notificationContent,
nm.notification.isSystemGenerated,
nm.createdAt
)
from NotificationMapper nm
join nm.notification n
where nm.userId.id = :appUserId
and nm.isRead = :isRead
and nm.isRead = false
""", countQuery = """
select count(nm)
from NotificationMapper nm
where nm.userId.id = :appUserId
and nm.isRead = :isRead
and nm.isRead = false
""")
Page<NotificationData> findNotificationDataByUserIdAndReadStatus(@Param("appUserId") Long appUserId, @Param("isRead") Boolean isRead,
Pageable pageable);
Page<NotificationData> findUnreadNotificationDataByUserId(@Param("appUserId") Long appUserId, Pageable pageable);
}
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public Page<NotificationData> getAllUnreadNotifications(final SearchParameters s
final Long appUserId = context.authenticatedUser().getId();
final Pageable pageable = toPageable(searchParameters);
final org.springframework.data.domain.Page<NotificationData> springPage = this.notificationMapperRepository
.findNotificationDataByUserIdAndReadStatus(appUserId, false, pageable);
.findUnreadNotificationDataByUserId(appUserId, pageable);
return toFineractPage(springPage);
}

Expand Down