aliases/implications: default listing to newest first.
Change alias and implication index pages from listing aliases/implications by pending first to newest first.
This commit is contained in:
@@ -98,11 +98,7 @@ class TagRelationship < ApplicationRecord
|
|||||||
|
|
||||||
def pending_first
|
def pending_first
|
||||||
# unknown statuses return null and are sorted first
|
# unknown statuses return null and are sorted first
|
||||||
order(Arel.sql("array_position(array['queued', 'processing', 'pending', 'active', 'deleted', 'retired'], status::text) NULLS FIRST, antecedent_name, consequent_name"))
|
order(Arel.sql("array_position(array['queued', 'processing', 'pending', 'active', 'deleted', 'retired'], status::text) NULLS FIRST, id DESC"))
|
||||||
end
|
|
||||||
|
|
||||||
def default_order
|
|
||||||
pending_first
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def search(params)
|
def search(params)
|
||||||
@@ -124,8 +120,7 @@ class TagRelationship < ApplicationRecord
|
|||||||
q = q.joins(:consequent_tag).where("tags.category": params[:category].split)
|
q = q.joins(:consequent_tag).where("tags.category": params[:category].split)
|
||||||
end
|
end
|
||||||
|
|
||||||
params[:order] ||= "status"
|
case params[:order].to_s.downcase
|
||||||
case params[:order].downcase
|
|
||||||
when "created_at"
|
when "created_at"
|
||||||
q = q.order("created_at desc")
|
q = q.order("created_at desc")
|
||||||
when "updated_at"
|
when "updated_at"
|
||||||
@@ -134,6 +129,8 @@ class TagRelationship < ApplicationRecord
|
|||||||
q = q.order("antecedent_name asc, consequent_name asc")
|
q = q.order("antecedent_name asc, consequent_name asc")
|
||||||
when "tag_count"
|
when "tag_count"
|
||||||
q = q.joins(:consequent_tag).order("tags.post_count desc, antecedent_name asc, consequent_name asc")
|
q = q.joins(:consequent_tag).order("tags.post_count desc, antecedent_name asc, consequent_name asc")
|
||||||
|
when "status"
|
||||||
|
q = q.pending_first
|
||||||
else
|
else
|
||||||
q = q.apply_default_order(params)
|
q = q.apply_default_order(params)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -10,6 +10,6 @@
|
|||||||
<%= fa.input :category, label: "To Category", collection: TagCategory.canonical_mapping.to_a, include_blank: true, selected: params.dig(:search, :consequent_tag, :category) %>
|
<%= fa.input :category, label: "To Category", collection: TagCategory.canonical_mapping.to_a, include_blank: true, selected: params.dig(:search, :consequent_tag, :category) %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<%= f.input :status, label: "Status", collection: %w[Approved Active Pending Deleted Retired Processing Queued], include_blank: true, selected: params[:search][:status] %>
|
<%= f.input :status, label: "Status", collection: %w[Approved Active Pending Deleted Retired Processing Queued], include_blank: true, selected: params[:search][:status] %>
|
||||||
<%= f.input :order, label: "Order", collection: [%w[Status status], %w[Recently\ created created_at], %w[Recently\ updated updated_at], %w[Name name], %w[Tag\ count tag_count]], selected: params[:search][:order] %>
|
<%= f.input :order, label: "Order", collection: [%w[Created created_at], %w[Updated updated_at], %w[Name name], %w[Tag\ count tag_count], %w[Status status]], include_blank: true, selected: params[:search][:order] %>
|
||||||
<%= f.submit "Search" %>
|
<%= f.submit "Search" %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|||||||
Reference in New Issue
Block a user