From 3812e398bfb8b3052604cba0146a35d1713d1f34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergei=20Ts=C3=B5ganov?= Date: Mon, 6 Jun 2022 16:24:38 +0300 Subject: [PATCH] Fixed codeclimate errors --- .../repp/v1/registrar/summary_controller.rb | 28 ++++++++----------- lib/serializers/repp/invoice.rb | 2 +- 2 files changed, 12 insertions(+), 18 deletions(-) diff --git a/app/controllers/repp/v1/registrar/summary_controller.rb b/app/controllers/repp/v1/registrar/summary_controller.rb index 0885d822a..d3865bed2 100644 --- a/app/controllers/repp/v1/registrar/summary_controller.rb +++ b/app/controllers/repp/v1/registrar/summary_controller.rb @@ -12,7 +12,6 @@ module Repp user_notifications = user.unread_notifications notification = user_notifications.order('created_at DESC').take end - render_success(data: serialize_data(registrar: registrar, notification: notification, notifications_count: user_notifications&.count, @@ -45,23 +44,18 @@ module Repp # rubocop:disable Style/RescueStandardError 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 - - begin - object_by_type(notification.attached_obj_type) - .find(notification.attached_obj_id) - rescue => e - # the data model might be inconsistent; or ... - # this could happen if the registrar does not dequeue messages, - # and then the domain was deleted - # SELECT messages.id, domains.name, messages.body FROM messages LEFT OUTER - # 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 + object_by_type(notification.attached_obj_type).find(notification.attached_obj_id) + rescue => e + # the data model might be inconsistent; or ... + # this could happen if the registrar does not dequeue messages, + # and then the domain was deleted + # SELECT messages.id, domains.name, messages.body FROM messages LEFT OUTER + # 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 # rubocop:enable Style/RescueStandardError diff --git a/lib/serializers/repp/invoice.rb b/lib/serializers/repp/invoice.rb index f4ab4a1db..3b8efbd58 100644 --- a/lib/serializers/repp/invoice.rb +++ b/lib/serializers/repp/invoice.rb @@ -37,7 +37,7 @@ module Serializers address: invoice.seller_address, country: invoice.seller_country.name, phone: invoice.seller_phone, url: invoice.seller_url, email: invoice.seller_email, - contact_name: invoice.seller_contact_name, + contact_name: invoice.seller_contact_name } end