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,23 +44,18 @@ 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)
rescue => e
begin # the data model might be inconsistent; or ...
object_by_type(notification.attached_obj_type) # this could happen if the registrar does not dequeue messages,
.find(notification.attached_obj_id) # and then the domain was deleted
rescue => e # SELECT messages.id, domains.name, messages.body FROM messages LEFT OUTER
# the data model might be inconsistent; or ... # JOIN domains ON attached_obj_id::INTEGER = domains.id
# this could happen if the registrar does not dequeue messages, # WHERE attached_obj_type = 'Epp::Domain' AND name IS NULL;
# and then the domain was deleted message = 'orphan message, domain deleted, registrar should dequeue: '
# SELECT messages.id, domains.name, messages.body FROM messages LEFT OUTER Rails.logger.error message + e.to_s
# JOIN domains ON attached_obj_id::INTEGER = domains.id
# WHERE attached_obj_type = 'Epp::Domain' AND name IS NULL;
message = 'orphan message, domain deleted, registrar should dequeue: '
Rails.logger.error message + e.to_s
end
end end
# rubocop:enable Style/RescueStandardError # rubocop:enable Style/RescueStandardError

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