Fixed codeclimate errors

This commit is contained in:
Sergei Tsõganov 2022-06-06 16:24:38 +03:00
parent 7c570e2916
commit 3812e398bf
2 changed files with 12 additions and 18 deletions

View file

@ -12,7 +12,6 @@ module Repp
user_notifications = user.unread_notifications user_notifications = user.unread_notifications
notification = user_notifications.order('created_at DESC').take notification = user_notifications.order('created_at DESC').take
end end
render_success(data: serialize_data(registrar: registrar, render_success(data: serialize_data(registrar: registrar,
notification: notification, notification: notification,
notifications_count: user_notifications&.count, notifications_count: user_notifications&.count,
@ -45,13 +44,9 @@ module Repp
# rubocop:disable Style/RescueStandardError # rubocop:disable Style/RescueStandardError
def notification_object(notification) def notification_object(notification)
return unless notification return unless notification&.attached_obj_type || notification&.attached_obj_id
return unless notification.attached_obj_type || notification.attached_obj_id object_by_type(notification.attached_obj_type).find(notification.attached_obj_id)
begin
object_by_type(notification.attached_obj_type)
.find(notification.attached_obj_id)
rescue => e rescue => e
# the data model might be inconsistent; or ... # the data model might be inconsistent; or ...
# this could happen if the registrar does not dequeue messages, # this could happen if the registrar does not dequeue messages,
@ -62,7 +57,6 @@ module Repp
message = 'orphan message, domain deleted, registrar should dequeue: ' message = 'orphan message, domain deleted, registrar should dequeue: '
Rails.logger.error message + e.to_s Rails.logger.error message + e.to_s
end end
end
# rubocop:enable Style/RescueStandardError # rubocop:enable Style/RescueStandardError
def object_by_type(object_type) def object_by_type(object_type)

View file

@ -37,7 +37,7 @@ module Serializers
address: invoice.seller_address, country: invoice.seller_country.name, address: invoice.seller_address, country: invoice.seller_country.name,
phone: invoice.seller_phone, url: invoice.seller_url, phone: invoice.seller_phone, url: invoice.seller_url,
email: invoice.seller_email, email: invoice.seller_email,
contact_name: invoice.seller_contact_name, contact_name: invoice.seller_contact_name
} }
end end