diff --git a/app/controllers/stories_controller.rb b/app/controllers/stories_controller.rb index a297cf223..f883bee25 100644 --- a/app/controllers/stories_controller.rb +++ b/app/controllers/stories_controller.rb @@ -87,6 +87,12 @@ class StoriesController < ApplicationController return end + @num_published_articles = if @tag_model.requires_approval? + Article.published.cached_tagged_by_approval_with(@tag).size + else + Article.published.cached_tagged_with(@tag).size + end + @stories = Articles::Feed.new(number_of_articles: 8, tag: @tag).published_articles_by_tag @stories = @stories.where(approved: true) if @tag_model&.requires_approval diff --git a/app/models/article.rb b/app/models/article.rb index e579251b6..ff3f2a935 100644 --- a/app/models/article.rb +++ b/app/models/article.rb @@ -80,6 +80,8 @@ class Article < ApplicationRecord scope :cached_tagged_with, ->(tag) { where("cached_tag_list ~* ?", "^#{tag},| #{tag},|, #{tag}$|^#{tag}$") } + scope :cached_tagged_by_approval_with, ->(tag) { cached_tagged_with(tag).where(approved: true) } + scope :active_help, lambda { published. cached_tagged_with("help"). diff --git a/app/views/articles/tags/_sidebar.html.erb b/app/views/articles/tags/_sidebar.html.erb index ff617cf09..f19eff703 100644 --- a/app/views/articles/tags/_sidebar.html.erb +++ b/app/views/articles/tags/_sidebar.html.erb @@ -63,7 +63,7 @@ <% end %>