7992 wrap local_posts from statistics in a cache

This commit is contained in:
Thorsten Claus 2021-05-09 10:17:30 +02:00 committed by Benjamin Neff
parent ba905334f7
commit d4331f4e65
No known key found for this signature in database
GPG key ID: 971464C3F1A90194

View file

@ -105,10 +105,12 @@ class NodeInfoPresenter
end end
def local_posts def local_posts
@local_posts ||= Post.where(type: "StatusMessage") Rails.cache.fetch("NodeInfoPresenter/local_posts", expires_in: 1.hours) do
.joins(:author) @local_posts ||= Post.where(type: "StatusMessage")
.where("owner_id IS NOT null") .joins(:author)
.count .where("owner_id IS NOT null")
.count
end
end end
def local_comments def local_comments