Skip to content

Commit

Permalink
#11451 Send total number of notifications in getNotifications end poi…
Browse files Browse the repository at this point in the history
…nt (#11523)
  • Loading branch information
freddyDOTCMS authored and jgambarios committed May 8, 2017
1 parent 6b3ae06 commit 957bdc0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ protected Long getUserCount(final String userId) {

Long count = null;
final String primaryKey =
this.getUserCountPrimaryKey(userId);
this.getAllNotificationsPrimaryKey(userId);

try {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,12 @@ public Response getNotifications (@Context final HttpServletRequest request,
//notificationAPI.markNotificationsAsRead(user.getUserId());

// Let's get the total count
final Long total = allUsers ?
this.notificationAPI.getNotificationsCount():
Long notificationsCount = allUsers ?
this.notificationAPI.getNotificationsCount() :
this.notificationAPI.getNotificationsCount(user.getUserId());

final Long totalUnreadNotifications = allUsers ?
this.notificationAPI.getNotificationsCount() :
this.notificationAPI.getNewNotificationsCount(user.getUserId());

final List<Notification> notifications = allUsers ?
Expand All @@ -139,8 +143,9 @@ public Response getNotifications (@Context final HttpServletRequest request,
});
}

return Response.ok(new ResponseEntityView(map("count", total, "notifications", notificationsResult)))
.header("Content-Range", "items " + offset + "-" + limit + "/" + total)
return Response.ok(new ResponseEntityView(map("totalUnreadNotifications", totalUnreadNotifications,
"notifications", notificationsResult, "total", notificationsCount)))
.header("Content-Range", "items " + offset + "-" + limit + "/" + totalUnreadNotifications)
.build(); // 200
} catch (Exception e) { // this is an unknown error, so we report as a 500.

Expand Down

0 comments on commit 957bdc0

Please sign in to comment.