Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions app/controllers/collections_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@ class CollectionsController < ApplicationController
before_action :get_creators, except: [:index, :create]

def index
@models = filtered_models @filters
@collections = policy_scope(Collection)
@collections = filtered_collections @filters
unless @filters.empty?
@models = filtered_models @filters
@collections = filtered_collections @filters
end

@tags, @unrelated_tag_count = generate_tag_list(@models, @filter_tags)
@tags, @kv_tags = split_key_value_tags(@tags)
Expand Down
6 changes: 4 additions & 2 deletions app/controllers/creators_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@ class CreatorsController < ApplicationController
before_action :get_creator, except: [:index, :new, :create]

def index
@models = filtered_models @filters
@creators = policy_scope(Creator)
@creators = @creators.where(id: @models.pluck(:creator_id).uniq) unless @filters.empty?
unless @filters.empty?
@models = filtered_models @filters
@creators = @creators.where(id: @models.pluck(:creator_id).uniq)
end

@tags, @unrelated_tag_count = generate_tag_list(@models, @filter_tags)
@tags, @kv_tags = split_key_value_tags(@tags)
Expand Down
3 changes: 2 additions & 1 deletion app/views/collections/_collection.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@
</ul>
</div>
<div>
<%= link_to "#{policy_scope(Model).where(collection: collection).count} #{Model.model_name.human count: policy_scope(Model).where(collection: collection).count}", collection, class: "btn btn-primary", "aria-label": translate(".models_button.label", name: collection.name) if policy(collection).show? %>
<% model_count = policy_scope(Model).where(collection: collection).count %>
<%= link_to "#{model_count} #{Model.model_name.human count: model_count}", collection, class: "btn btn-primary", "aria-label": translate(".models_button.label", name: collection.name) if policy(collection).show? %>
<%= link_to "#{collection.collections.count} #{Collection.model_name.human count: collection.collections.count}", (@filters || {}).merge(controller: "collections", collection: collection), class: "btn btn-primary", "aria-label": translate(".collections_button.label", name: collection.name) if collection.collections.count > 0 && policy(collection).show? %>
<%= link_to icon("pencil-fill", t(".edit_button.text")), edit_collection_path(collection), {class: "btn btn-outline-secondary", "aria-label": translate(".edit_button.label", name: collection.name)} if policy(collection).edit? %>
</div>
Expand Down
3 changes: 2 additions & 1 deletion app/views/collections/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
<div class="col">
<%= content_tag(:p, class: "lead") { @collection.caption } if @collection.caption %>
<%= content_tag(:p, class: "card-text") { markdownify @collection.notes } if @collection.notes %>
<p><%= "#{policy_scope(Model).where(collection: @collection).count} #{Model.model_name.human count: policy_scope(Model).where(collection: @collection).count}" %></p>
<% model_count = policy_scope(Model).where(collection: @collection).count %>
<p><%= "#{model_count} #{Model.model_name.human count: model_count}" %></p>
<%= content_tag(:p) { t("general.followers", count: @collection.followers.count) } if SiteSettings.social_enabled? %>
</div>
</div>
Expand Down
10 changes: 6 additions & 4 deletions app/views/creators/_creator.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@
<ul class='links'>
<%= render LinkComponent.with_collection creator.links %>
</ul>
<% model_count = policy_scope(Model).where(creator: creator).count %>
<% collection_count = policy_scope(Collection).where(creator: creator).count %>
<% if creator.remote? %>
<%= link_to "#{policy_scope(Model).where(creator: creator).count} #{Model.model_name.human count: policy_scope(Model).where(creator: creator).count}", creator, {class: "btn btn-primary", "aria-label": translate(".models_button.remote_label", name: creator.name)} if policy(creator).show? %>
<%= link_to "#{policy_scope(Collection).where(creator: creator).count} #{Collection.model_name.human count: policy_scope(Collection).where(creator: creator).count}", "collections?creator=" + creator.to_param, {class: "btn btn-primary", "aria-label": translate(".models_button.remote_label", name: creator.name)} if policy(creator).show? && !creator.collections.empty? %>
<%= link_to "#{model_count} #{Model.model_name.human count: model_count}", creator, {class: "btn btn-primary", "aria-label": translate(".models_button.remote_label", name: creator.name)} if policy(creator).show? %>
<%= link_to "#{collection_count} #{Collection.model_name.human count: collection_count}", "collections?creator=" + creator.to_param, {class: "btn btn-primary", "aria-label": translate(".models_button.remote_label", name: creator.name)} if policy(creator).show? && !creator.collections.empty? %>
<%= link_to "⁂", creator.federails_actor.profile_url, {class: "btn btn-outline-secondary", "aria-label": translate(".visit_button.label", name: creator.name, target: "new")} %>
<% else %>
<%= link_to "#{policy_scope(Model).where(creator: creator).count} #{Model.model_name.human count: policy_scope(Model).where(creator: creator).count}", creator, {class: "btn btn-primary", "aria-label": translate(".models_button.label", name: creator.name)} if policy(creator).show? %>
<%= link_to "#{policy_scope(Collection).where(creator: creator).count} #{Collection.model_name.human count: policy_scope(Collection).where(creator: creator).count}", "collections?creator=" + creator.to_param, {class: "btn btn-primary", "aria-label": translate(".models_button.label", name: creator.name)} if policy(creator).show? && !creator.collections.empty? %>
<%= link_to "#{model_count} #{Model.model_name.human count: model_count}", creator, {class: "btn btn-primary", "aria-label": translate(".models_button.label", name: creator.name)} if policy(creator).show? %>
<%= link_to "#{collection_count} #{Collection.model_name.human count: collection_count}", "collections?creator=" + creator.to_param, {class: "btn btn-primary", "aria-label": translate(".models_button.label", name: creator.name)} if policy(creator).show? && !creator.collections.empty? %>
<%= link_to icon("pencil-fill", t(".edit_button.text")), edit_creator_path(creator), {class: "btn btn-outline-secondary", "aria-label": translate(".edit_button.label", name: creator.name)} if policy(creator).edit? %>
<% end %>
</div>
Expand Down
3 changes: 2 additions & 1 deletion app/views/creators/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
<div class="col">
<%= content_tag(:p, class: "lead") { @creator.caption } if @creator.caption %>
<%= content_tag(:p, class: "card-text") { markdownify @creator.notes } if @creator.notes %>
<p><%= "#{policy_scope(Model).where(creator: @creator).count} #{Model.model_name.human count: policy_scope(Model).where(creator: @creator).count}" %></p>
<% model_count = policy_scope(Model).where(creator: @creator).count %>
<p><%= "#{model_count} #{Model.model_name.human count: model_count}" %></p>
<%= content_tag(:p) { t("general.followers", count: @creator.followers.count) } if SiteSettings.social_enabled? %>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion config/initializers/bullet.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
# Features
Bullet.n_plus_one_query_enable = true
Bullet.unused_eager_loading_enable = true
Bullet.counter_cache_enable = false
Bullet.counter_cache_enable = true
end
end
Loading