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:
Ben Halpern 2018-11-19 20:36:35 -05:00 committed by GitHub
parent 044de6a8b5
commit b2d46fed65
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 5 deletions

View file

@ -23,7 +23,7 @@ function markNotificationsAsRead() {
xmlhttp.setRequestHeader('X-CSRF-Token', csrfToken);
xmlhttp.send();
}
}, 250);
}, 380);
}
function fetchNotificationsCount() {

View file

@ -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