docbrown/app/controllers/notifications_controller.rb
Ben Halpern 115e52c748
Move follow and reaction aggregation into Notification model to avoid… (#1164)
* Move follow and reaction aggregation into Notification model to avoid re-compute

* Ugh. Fixing schema

* Update tests

* Skip some tests in notifications_spec
2018-11-20 15:00:21 -05:00

20 lines
693 B
Ruby

class NotificationsController < ApplicationController
# No authorization required because we provide authentication on notifications page
def index
if user_signed_in?
@notifications_index = true
@user = if params[:username] && current_user.admin?
User.find_by_username(params[:username])
else
current_user
end
@notifications = NotificationDecorator.
decorate_collection(Notification.where(user_id: current_user.id).
order("notified_at DESC").limit(60).to_a)
@last_user_reaction = @user.reactions.last&.id
@last_user_comment = @user.comments.last&.id
end
end
private
end