From aceded710ab2c4b8b9a22cd12bd840f464fd597b Mon Sep 17 00:00:00 2001 From: evazion Date: Mon, 31 Dec 2018 17:07:14 -0600 Subject: [PATCH] aliases/implications: fix retired aliases being sorted first on index page. --- app/models/tag_relationship.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/models/tag_relationship.rb b/app/models/tag_relationship.rb index d5f3ae289..7b92d1ba1 100644 --- a/app/models/tag_relationship.rb +++ b/app/models/tag_relationship.rb @@ -80,7 +80,8 @@ class TagRelationship < ApplicationRecord end def pending_first - order(Arel.sql("(case status when 'pending' then 1 when 'queued' then 2 when 'active' then 3 else 0 end), antecedent_name, consequent_name")) + # unknown statuses return null and are sorted first + order(Arel.sql("array_position(array['queued', 'processing', 'pending', 'active', 'deleted', 'retired'], status) NULLS FIRST, antecedent_name, consequent_name")) end def active