Skip to content

Commit

Permalink
Merge pull request #2425 from internetee/45-fix-domains-registrant-fi…
Browse files Browse the repository at this point in the history
…lter

Fixed domains search by registrant
  • Loading branch information
vohmar authored Aug 23, 2022
2 parents a5f803b + 931e390 commit ff74527
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions app/controllers/repp/v1/domains_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ class DomainsController < BaseController # rubocop:disable Metrics/ClassLength
desc 'Get all existing domains'
def index
authorize! :info, Epp::Domain
records = current_user.registrar.domains
records = current_user.registrar.domains.includes(:registrar, :registrant)
q = records.ransack(PartialSearchFormatter.format(search_params))
q.sorts = ['valid_to asc', 'created_at desc'] if q.sorts.empty?
# use distinct: false here due to ransack bug:
# https://github.com/activerecord-hackery/ransack/issues/429
domains = q.result(distinct: false)

limited_domains = domains.limit(limit).offset(offset).includes(:registrar, :registrant)
limited_domains = domains.limit(limit).offset(offset)

render_success(data: { new_domain: records.any? ? serialized_domains([records.last]) : [],
domains: serialized_domains(limited_domains.to_a.uniq),
Expand Down Expand Up @@ -238,7 +238,7 @@ def offset

def index_params
params.permit(:limit, :offset, :details, :simple, :q,
q: %i[s name_matches registrant_id_eq contacts_ident_eq
q: %i[s name_matches registrant_code_eq contacts_ident_eq
nameservers_hostname_eq valid_to_gteq valid_to_lteq
statuses_contains_array] + [s: []])
end
Expand Down

0 comments on commit ff74527

Please sign in to comment.