From d4331f4e65781a9813f3cd991885115e4a603eef Mon Sep 17 00:00:00 2001 From: Thorsten Claus Date: Sun, 9 May 2021 10:17:30 +0200 Subject: [PATCH 1/7] 7992 wrap local_posts from statistics in a cache --- app/presenters/node_info_presenter.rb | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/app/presenters/node_info_presenter.rb b/app/presenters/node_info_presenter.rb index e0c2c579b..045cd8c65 100644 --- a/app/presenters/node_info_presenter.rb +++ b/app/presenters/node_info_presenter.rb @@ -105,10 +105,12 @@ class NodeInfoPresenter end def local_posts - @local_posts ||= Post.where(type: "StatusMessage") - .joins(:author) - .where("owner_id IS NOT null") - .count + Rails.cache.fetch("NodeInfoPresenter/local_posts", expires_in: 1.hours) do + @local_posts ||= Post.where(type: "StatusMessage") + .joins(:author) + .where("owner_id IS NOT null") + .count + end end def local_comments From 704223721870bcb9dece55c6073d637cbb41216c Mon Sep 17 00:00:00 2001 From: Thorsten Claus Date: Sun, 9 May 2021 10:23:07 +0200 Subject: [PATCH 2/7] Styles, SQL format --- app/presenters/node_info_presenter.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/presenters/node_info_presenter.rb b/app/presenters/node_info_presenter.rb index 045cd8c65..343981422 100644 --- a/app/presenters/node_info_presenter.rb +++ b/app/presenters/node_info_presenter.rb @@ -105,17 +105,17 @@ class NodeInfoPresenter end def local_posts - Rails.cache.fetch("NodeInfoPresenter/local_posts", expires_in: 1.hours) do + Rails.cache.fetch("NodeInfoPresenter/local_posts", expires_in: 1.hour) do @local_posts ||= Post.where(type: "StatusMessage") - .joins(:author) - .where("owner_id IS NOT null") - .count + .joins(:author) + .where.not(people: {owner_id: nil}) + .count end end def local_comments @local_comments ||= Comment.joins(:author) - .where("owner_id IS NOT null") + .where.not(people: {owner_id: nil}) .count end end From 1f510d0b40143d0a2a34d1fd4332936e86e1a8aa Mon Sep 17 00:00:00 2001 From: Thorsten Claus Date: Sat, 12 Jun 2021 07:35:02 +0200 Subject: [PATCH 3/7] Wrapped local_comments also in a cache closes #8241 closes #7992 --- Changelog.md | 1 + app/presenters/node_info_presenter.rb | 8 +++++--- 2 files changed, 6 insertions(+), 3 deletions(-) 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 From 92a096f03cf0612d05696954ca162da219091950 Mon Sep 17 00:00:00 2001 From: Pirate Praveen Date: Sat, 3 Oct 2020 18:07:25 +0530 Subject: [PATCH 4/7] Add closing tags to replace invalid self-closing tags closes #8251 closes #8158 --- Changelog.md | 1 + .../aspect_membership_dropdown_tpl.jst.hbs | 10 +++++----- app/assets/templates/comment-stream_tpl.jst.hbs | 2 +- app/assets/templates/comment_tpl.jst.hbs | 4 ++-- app/assets/templates/photo_tpl.jst.hbs | 4 ++-- app/assets/templates/pod_table_entry_tpl.jst.hbs | 6 +++--- app/assets/templates/reshare_tpl.jst.hbs | 2 +- .../single-post-content_tpl.jst.hbs | 14 +++++++------- app/assets/templates/stream-element_tpl.jst.hbs | 2 +- 9 files changed, 23 insertions(+), 22 deletions(-) diff --git a/Changelog.md b/Changelog.md index c69a19341..a20ada372 100644 --- a/Changelog.md +++ b/Changelog.md @@ -2,6 +2,7 @@ ## Refactor * Cache local posts/comments count for statistics [#8241](https://github.com/diaspora/diaspora/pull/8241) +* Fix html-syntax in some handlebars templates [#8251](https://github.com/diaspora/diaspora/pull/8251) ## Bug fixes diff --git a/app/assets/templates/aspect_membership_dropdown_tpl.jst.hbs b/app/assets/templates/aspect_membership_dropdown_tpl.jst.hbs index 03e24c939..f4a96f1c2 100644 --- a/app/assets/templates/aspect_membership_dropdown_tpl.jst.hbs +++ b/app/assets/templates/aspect_membership_dropdown_tpl.jst.hbs @@ -10,7 +10,7 @@ {{ t "aspect_dropdown.toggle" count=aspectMembershipsLength }} {{/if}} - + {{#if dropdownMayCreateNewAspect}} - diff --git a/app/assets/templates/pod_table_entry_tpl.jst.hbs b/app/assets/templates/pod_table_entry_tpl.jst.hbs index e43ee6c6f..46f0a9909 100644 --- a/app/assets/templates/pod_table_entry_tpl.jst.hbs +++ b/app/assets/templates/pod_table_entry_tpl.jst.hbs @@ -9,7 +9,7 @@ {{host}} - + {{#if has_no_errors}} @@ -18,10 +18,10 @@ {{status_text}} {{/if}} {{#unless is_unchecked}} -
{{t 'admin.pods.last_check'}} +
{{t 'admin.pods.last_check'}} {{/unless}} {{#if offline}} - | {{t 'admin.pods.offline_since'}} + | {{t 'admin.pods.offline_since'}} {{/if}} {{#if is_unchecked}}
{{t 'admin.pods.no_info'}}{{/if}}