0
0
Fork 0

Change grouped notifications API shape (take 2) (#31214)

This commit is contained in:
Claire 2024-07-31 12:50:13 +02:00 committed by GitHub
parent 288961bbb9
commit 549ab089ee
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 70 additions and 20 deletions

View 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