From c02101aa66636500b317f8ae91248e6742b9b25a Mon Sep 17 00:00:00 2001 From: Thiago Youssef Date: Mon, 16 May 2022 14:04:44 +0300 Subject: [PATCH] Fix code climate --- app/interactions/actions/email_check.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/interactions/actions/email_check.rb b/app/interactions/actions/email_check.rb index f83f2dd2c5..a927a32741 100644 --- a/app/interactions/actions/email_check.rb +++ b/app/interactions/actions/email_check.rb @@ -26,8 +26,8 @@ def calculate_check_level Rails.env.test? && check_level == 'smtp' ? :mx : check_level.to_sym end - def destroy_old_validations(validation_events, minimum_size) - return unless validation_events.count > minimum_size + def destroy_old_validations(validation_events, minimum_size, check_level) + return unless validation_events.count > minimum_size && @check_level == check_level validation_events.order!(created_at: :asc) validation_events.first.destroy while validation_events.count > minimum_size @@ -36,11 +36,11 @@ def destroy_old_validations(validation_events, minimum_size) def filtering_old_failed_records(result) events = validation_eventable.validation_events - destroy_old_validations(events, ValidationEvent::MX_CHECK) if @check_level == 'mx' && !result.success + destroy_old_validations(events, ValidationEvent::MX_CHECK, 'mx') unless result.success - destroy_old_validations(events, ValidationEvent::REDEEM_EVENTS_COUNT_BY_LEVEL[:mx]) if @check_level == 'mx' && result.success + destroy_old_validations(events, ValidationEvent::REDEEM_EVENTS_COUNT_BY_LEVEL[:mx], 'mx') if result.success - destroy_old_validations(events, ValidationEvent::REDEEM_EVENTS_COUNT_BY_LEVEL[:smtp]) if @check_level == 'smtp' + destroy_old_validations(events, ValidationEvent::REDEEM_EVENTS_COUNT_BY_LEVEL[:smtp], 'smtp') end def save_result(result)