Skip to content

Commit

Permalink
AO3-4858 Tag wrangling pages should allow sorting by taggings_count_c…
Browse files Browse the repository at this point in the history
…ache (#2822)

* AO3-4858 Allow sorting tag wrangling pages by taggings_count_cache

* AO3-4858 Don't use tagging_count_cache in for the display on the wrangling page
  • Loading branch information
sarken authored and zz9pzza committed Mar 28, 2017
1 parent 70b3c2b commit 25f9fe8
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion app/controllers/application_controller.rb
Expand Up @@ -415,7 +415,7 @@ def valid_sort_column(param, model='work')
if model.to_s.downcase == 'work'
allowed = ['author', 'title', 'date', 'created_at', 'word_count', 'hit_count']
elsif model.to_s.downcase == 'tag'
allowed = ['name', 'created_at', 'suggested_fandoms', 'taggings_count']
allowed = ['name', 'created_at', 'suggested_fandoms', 'taggings_count_cache']
elsif model.to_s.downcase == 'collection'
allowed = ['collections.title', 'collections.created_at']
elsif model.to_s.downcase == 'prompt'
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/tag_wranglings_controller.rb
Expand Up @@ -18,7 +18,7 @@ def index
params[:sort_column] = 'created_at' if !valid_sort_column(params[:sort_column], 'tag')
params[:sort_direction] = 'ASC' if !valid_sort_direction(params[:sort_direction])
sort = params[:sort_column] + " " + params[:sort_direction]
sort = sort + ", name ASC" if sort.include?('taggings_count')
sort = sort + ", name ASC" if sort.include?('taggings_count_cache')
if params[:show] == "fandoms"
@media_names = Media.by_name.value_of(:name)
@page_subtitle = ts("fandoms")
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/tags_controller.rb
Expand Up @@ -293,7 +293,7 @@ def wrangle
params[:sort_direction] = 'ASC' unless valid_sort_direction(params[:sort_direction])
sort = params[:sort_column] + ' ' + params[:sort_direction]
# add a secondary sorting key when the main one is not discerning enough
if sort.include?('suggested') || sort.include?('taggings_count')
if sort.include?('suggested') || sort.include?('taggings_count_cache')
sort += ', name ASC'
end
# this makes sure params[:status] is safe
Expand Down
2 changes: 1 addition & 1 deletion app/views/tag_wranglings/index.html.erb
Expand Up @@ -89,7 +89,7 @@
</ul>
</th>
<th scope="col" title="<%= ts('sort by') %>">
<%= sort_link ts('Taggings'), :taggings_count_cache, {desc_default: true} %>
<%= sort_link ts('Taggings'), :taggings_count_cache, { desc_default: true } %>
</th>
<th scope="col"><%= ts('Manage') %></th>
</tr>
Expand Down

0 comments on commit 25f9fe8

Please sign in to comment.