Lessen amount of notifications queried slightly to improve performance (#1159)
* Lessen amount of notifications queried slightly to improve performance * Guard for last_user_reaction
This commit is contained in:
parent
044de6a8b5
commit
b2d46fed65
2 changed files with 5 additions and 5 deletions
|
|
@ -23,7 +23,7 @@ function markNotificationsAsRead() {
|
|||
xmlhttp.setRequestHeader('X-CSRF-Token', csrfToken);
|
||||
xmlhttp.send();
|
||||
}
|
||||
}, 250);
|
||||
}, 380);
|
||||
}
|
||||
|
||||
function fetchNotificationsCount() {
|
||||
|
|
|
|||
|
|
@ -8,12 +8,12 @@ class NotificationsController < ApplicationController
|
|||
else
|
||||
current_user
|
||||
end
|
||||
@notifications = Notification.where(user_id: current_user.id).order("created_at DESC").limit(500).to_a
|
||||
@notifications = Notification.where(user_id: current_user.id).order("created_at DESC").limit(400).to_a
|
||||
aggregate_notifications("Follow")
|
||||
aggregate_notifications("Reaction")
|
||||
@notifications = NotificationDecorator.decorate_collection(@notifications)[0..50]
|
||||
@last_user_reaction = @user.reactions.pluck(:id).last
|
||||
@last_user_comment = @user.comments.pluck(:id).last
|
||||
@notifications = NotificationDecorator.decorate_collection(@notifications)[0..40]
|
||||
@last_user_reaction = @user.reactions.last&.id
|
||||
@last_user_comment = @user.comments.last&.id
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue