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
## Refactor
* Cache local posts/comments count for statistics [#8241](https://github.com/diaspora/diaspora/pull/8241)
## Bug fixes

View file

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