Update the number of Published Posts to match the approved articles where necessary. (#6098)
* feat: the number of published posts should show up by approved article. * chore: Do not use spaces between -> and ( in lambda literals * refactor: use the existing function in order to spawn the one where we need approval * refactor: move logic to the controller instead of the view :) * chore: code climate syntax * chore: more codeclimate
This commit is contained in:
parent
88bddc13e8
commit
8641f0a93e
3 changed files with 9 additions and 1 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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").
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@
|
|||
<% end %>
|
||||
<div class="sidebar-data">
|
||||
<div>
|
||||
<%= pluralize Article.published.cached_tagged_with(@tag).size, "Post" %> Published
|
||||
<%= pluralize @num_published_articles, "Post" %> Published <%= %>
|
||||
</div>
|
||||
<% if user_signed_in? %>
|
||||
<span style="display:none;" id="tag-edit-button" data-tag="<%= @tag_model.name %>">
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue