Wrapped local_comments also in a cache

closes #8241
closes #7992
This commit is contained in:
Thorsten Claus 2021-06-12 07:35:02 +02:00 committed by Benjamin Neff
parent 7042237218
commit 1f510d0b40
No known key found for this signature in database
GPG key ID: 971464C3F1A90194
2 changed files with 6 additions and 3 deletions

View file

@ -1,6 +1,7 @@
# 0.7.16.0 # 0.7.16.0
## Refactor ## Refactor
* Cache local posts/comments count for statistics [#8241](https://github.com/diaspora/diaspora/pull/8241)
## Bug fixes ## Bug fixes

View file

@ -114,8 +114,10 @@ class NodeInfoPresenter
end end
def local_comments def local_comments
Rails.cache.fetch("NodeInfoPresenter/local_comments", expires_in: 1.hour) do
@local_comments ||= Comment.joins(:author) @local_comments ||= Comment.joins(:author)
.where.not(people: {owner_id: nil}) .where.not(people: {owner_id: nil})
.count .count
end end
end end
end