0
0
Fork 0

Improved performance of notification preloading (#15640)

* Improved performance of notification preloading

* Remove Cacheable from Notification

* Fix test
This commit is contained in:
abcang 2021-02-01 05:24:57 +09:00 committed by GitHub
parent c8c764dd8b
commit 7ab53f221a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 136 additions and 50 deletions

View file

@ -31,12 +31,13 @@ class Api::V1::NotificationsController < Api::BaseController
private
def load_notifications
cache_collection_paginated_by_id(
browserable_account_notifications,
Notification,
notifications = browserable_account_notifications.includes(from_account: :account_stat).to_a_paginated_by_id(
limit_param(DEFAULT_NOTIFICATIONS_LIMIT),
params_slice(:max_id, :since_id, :min_id)
)
Notification.preload_cache_collection_target_statuses(notifications) do |target_statuses|
cache_collection(target_statuses, Status)
end
end
def browserable_account_notifications