Appease the dog overlords
This commit is contained in:
parent
81a6c6ac55
commit
80e312eb3b
|
@ -16,11 +16,8 @@ class NotificationsController < ApplicationController
|
||||||
def index
|
def index
|
||||||
@type = TYPE_MAPPINGS[params[:type]] || params[:type]
|
@type = TYPE_MAPPINGS[params[:type]] || params[:type]
|
||||||
@notifications = cursored_notifications_for(type: @type, last_id: params[:last_id])
|
@notifications = cursored_notifications_for(type: @type, last_id: params[:last_id])
|
||||||
@notifications_last_id = @notifications.map(&:id).min
|
paginate_notifications
|
||||||
@more_data_available = !cursored_notifications_for(type: @type, last_id: @notifications_last_id, size: 1).count.zero?
|
@counters = count_unread_by_type
|
||||||
@counters = Notification.where(recipient: current_user, new: true)
|
|
||||||
.group(:target_type)
|
|
||||||
.count(:target_type)
|
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html
|
format.html
|
||||||
|
@ -30,6 +27,17 @@ class NotificationsController < ApplicationController
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
def paginate_notifications
|
||||||
|
@notifications_last_id = @notifications.map(&:id).min
|
||||||
|
@more_data_available = !cursored_notifications_for(type: @type, last_id: @notifications_last_id, size: 1).count.zero?
|
||||||
|
end
|
||||||
|
|
||||||
|
def count_unread_by_type
|
||||||
|
Notification.where(recipient: current_user, new: true)
|
||||||
|
.group(:target_type)
|
||||||
|
.count(:target_type)
|
||||||
|
end
|
||||||
|
|
||||||
def mark_notifications_as_read
|
def mark_notifications_as_read
|
||||||
# using .dup to not modify @notifications -- useful in tests
|
# using .dup to not modify @notifications -- useful in tests
|
||||||
@notifications&.dup&.update_all(new: false) # rubocop:disable Rails/SkipsModelValidations
|
@notifications&.dup&.update_all(new: false) # rubocop:disable Rails/SkipsModelValidations
|
||||||
|
|
Loading…
Reference in New Issue