Fixed codeclimate issues

This commit is contained in:
Sergei Tsõganov 2022-03-29 11:31:31 +03:00
parent b2bfc94121
commit 140e5dc22e
2 changed files with 10 additions and 8 deletions

View file

@ -40,6 +40,7 @@ class RegistrantUser < User
{ result: false, counter: 0 } { result: false, counter: 0 }
end end
# rubocop:disable Metrics/MethodLength
def update_contacts def update_contacts
user = self user = self
contacts = [] contacts = []
@ -55,9 +56,9 @@ class RegistrantUser < User
return [] if contacts.blank? return [] if contacts.blank?
group_and_bulk_update(contacts) group_and_bulk_update(contacts)
contacts contacts
end end
# rubocop:enable Metrics/MethodLength
def contacts(representable: true) def contacts(representable: true)
Contact.registrant_user_contacts(self, representable: representable) Contact.registrant_user_contacts(self, representable: representable)
@ -138,8 +139,7 @@ class RegistrantUser < User
private private
def group_and_bulk_update(contacts) def group_and_bulk_update(contacts)
grouped_contacts = contacts.group_by(&:registrar_id) contacts.group_by(&:registrar_id).each do |registrar_id, reg_contacts|
grouped_contacts.each do |registrar_id, reg_contacts|
bulk_action, action = actions.create!(operation: :bulk_update) if reg_contacts.size > 1 bulk_action, action = actions.create!(operation: :bulk_update) if reg_contacts.size > 1
reg_contacts.each do |c| reg_contacts.each do |c|
if c.save(validate: false) if c.save(validate: false)

View file

@ -8,10 +8,12 @@ builder.extension do
builder.tag!('changePoll:date', obj.created_at.utc.xmlschema) builder.tag!('changePoll:date', obj.created_at.utc.xmlschema)
builder.tag!('changePoll:svTRID', obj.id) builder.tag!('changePoll:svTRID', obj.id)
builder.tag!('changePoll:who', obj.user) builder.tag!('changePoll:who', obj.user)
if obj.bulk_action?
builder.tag!( builder.tag!(
'changePoll:reason', 'changePoll:reason',
'Auto-update according to official data' 'Auto-update according to official data'
) if obj.bulk_action? )
end
when 'state' when 'state'
builder.tag!('changePoll:operation', obj) builder.tag!('changePoll:operation', obj)
end end