Change grouped notifications API shape (take 2) (#31214)
This commit is contained in:
21
app/presenters/grouped_notifications_presenter.rb
Normal file
21
app/presenters/grouped_notifications_presenter.rb
Normal file
@@ -0,0 +1,21 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class GroupedNotificationsPresenter < ActiveModelSerializers::Model
|
||||
def initialize(grouped_notifications)
|
||||
super()
|
||||
|
||||
@grouped_notifications = grouped_notifications
|
||||
end
|
||||
|
||||
def notification_groups
|
||||
@grouped_notifications
|
||||
end
|
||||
|
||||
def statuses
|
||||
@grouped_notifications.filter_map(&:target_status).uniq(&:id)
|
||||
end
|
||||
|
||||
def accounts
|
||||
@grouped_notifications.flat_map(&:sample_accounts).uniq(&:id)
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user