Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed domains search by registrant #2425

Merged
merged 1 commit into from
Aug 23, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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