Change grouped notifications API shape (take 2) (#31214)
This commit is contained in:
parent
288961bbb9
commit
549ab089ee
9 changed files with 70 additions and 20 deletions
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
|
Loading…
Add table
Add a link
Reference in a new issue