Series count to only include non empty series (#16130)
Co-authored-by: Michael Kohl <me@citizen428.net>
This commit is contained in:
parent
f90459d163
commit
e2e54b35c6
4 changed files with 5 additions and 2 deletions
|
|
@ -1,7 +1,7 @@
|
|||
class CollectionsController < ApplicationController
|
||||
def index
|
||||
@user = User.find_by!(username: params[:username])
|
||||
@collections = @user.collections.joins(:articles).distinct.order(created_at: :desc)
|
||||
@collections = @user.collections.non_empty.order(created_at: :desc)
|
||||
end
|
||||
|
||||
def show
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ class DashboardsController < ApplicationController
|
|||
|
||||
@articles = @articles.includes(:collection).sorting(params[:sort]).decorate
|
||||
@articles = Kaminari.paginate_array(@articles).page(params[:page]).per(50)
|
||||
@collections_count = target.collections.non_empty.count
|
||||
end
|
||||
|
||||
def following_tags
|
||||
|
|
|
|||
|
|
@ -6,6 +6,8 @@ class Collection < ApplicationRecord
|
|||
|
||||
validates :slug, presence: true, uniqueness: { scope: :user_id }
|
||||
|
||||
scope :non_empty, -> { joins(:articles).distinct }
|
||||
|
||||
after_touch :touch_articles
|
||||
|
||||
def self.find_series(slug, user)
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
href="<%= user_series_path(current_user.username) %>"
|
||||
<%= params[:action] == "series" && (params[:which] == "organization" || params[:which].blank?) ? ' aria-current="page"'.html_safe : "" %>>
|
||||
<%= t("views.dashboard.actions.series") %>
|
||||
<span class="crayons-indicator"><%= @user.collections.count %></span>
|
||||
<span class="crayons-indicator"><%= @collections_count %></span>
|
||||
</a>
|
||||
</li>
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue