Skip to content

Commit

Permalink
Fix contact show bug
Browse files Browse the repository at this point in the history
  • Loading branch information
yulgolem committed Mar 24, 2020
1 parent bb6237e commit a5d1f63
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions app/models/contact.rb
Original file line number Diff line number Diff line change
Expand Up @@ -426,15 +426,14 @@ def all_domains(page: nil, per: nil, params:)
else
%Q{select domain_id from domain_contacts where contact_id=#{id} UNION select id from domains where registrant_id=#{id}}
end

# get sorting rules
sorts = params.fetch(:sort, {}).first || []
sort = Domain.column_names.include?(sorts.first) ? sorts.first : "valid_to"
sort = ::Domain.column_names.include?(sorts.first) ? sorts.first : "valid_to"
order = {"asc"=>"desc", "desc"=>"asc"}[sorts.second] || "desc"


# fetch domains
domains = Domain.where("domains.id IN (#{filter_sql})")
domains = ::Domain.where("domains.id IN (#{filter_sql})")
domains = domains.includes(:registrar).page(page).per(per)

if sorts.first == "registrar_name".freeze
Expand All @@ -444,8 +443,6 @@ def all_domains(page: nil, per: nil, params:)
domains = domains.order("#{sort} #{order} NULLS LAST")
end



# adding roles. Need here to make faster sqls
domain_c = Hash.new([])
registrant_domains.where(id: domains.map(&:id)).each{|d| domain_c[d.id] |= ["Registrant".freeze] }
Expand Down

0 comments on commit a5d1f63

Please sign in to comment.