diff --git a/Changelog.md b/Changelog.md index f2da13773..c69a19341 100644 --- a/Changelog.md +++ b/Changelog.md @@ -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 diff --git a/app/presenters/node_info_presenter.rb b/app/presenters/node_info_presenter.rb index 343981422..8eeda65d3 100644 --- a/app/presenters/node_info_presenter.rb +++ b/app/presenters/node_info_presenter.rb @@ -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