mirror of
https://github.com/internetee/registry.git
synced 2025-07-21 10:16:01 +02:00
Reduce domains list API call
This commit is contained in:
parent
556008debe
commit
7b33613941
2 changed files with 19 additions and 3 deletions
|
@ -20,7 +20,7 @@ module Api
|
|||
|
||||
domains = current_user_domains
|
||||
serialized_domains = domains.limit(limit).offset(offset).map do |item|
|
||||
serializer = Serializers::RegistrantApi::Domain.new(item)
|
||||
serializer = Serializers::RegistrantApi::Domain.new(item, simplify: true)
|
||||
serializer.to_json
|
||||
end
|
||||
|
||||
|
@ -31,7 +31,7 @@ module Api
|
|||
@domain = current_user_domains.find_by(uuid: params[:uuid])
|
||||
|
||||
if @domain
|
||||
serializer = Serializers::RegistrantApi::Domain.new(@domain)
|
||||
serializer = Serializers::RegistrantApi::Domain.new(@domain, simplify: false)
|
||||
render json: serializer.to_json
|
||||
else
|
||||
render json: { errors: [{ base: ['Domain not found'] }] }, status: :not_found
|
||||
|
|
|
@ -3,11 +3,27 @@ module Serializers
|
|||
class Domain
|
||||
attr_reader :domain
|
||||
|
||||
def initialize(domain)
|
||||
def initialize(domain, simplify: false)
|
||||
@domain = domain
|
||||
@simplify = simplify
|
||||
end
|
||||
|
||||
def to_json
|
||||
if simplify
|
||||
return {
|
||||
id: domain.uuid,
|
||||
name: domain.name,
|
||||
registered_at: domain.registered_at,
|
||||
valid_to: domain.valid_to,
|
||||
registrant_verification_asked_at: domain.registrant_verification_asked_at,
|
||||
statuses: domain.statuses,
|
||||
registrar: {
|
||||
name: domain.registrar.name,
|
||||
website: domain.registrar.website
|
||||
}
|
||||
}
|
||||
end
|
||||
|
||||
{
|
||||
id: domain.uuid,
|
||||
name: domain.name,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue