mirror of
https://github.com/internetee/registry.git
synced 2025-08-02 16:02:03 +02:00
Task remove all old validation event records
This commit is contained in:
parent
bbc1380e46
commit
4dcd6d765c
5 changed files with 28 additions and 53 deletions
|
@ -12,17 +12,12 @@ module Actions
|
|||
result = check_email(email)
|
||||
save_result(result)
|
||||
filtering_old_failed_records(result)
|
||||
remove_old_records!
|
||||
result.success ? log_success : log_failure(result)
|
||||
result.success
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def remove_old_records!
|
||||
validation_eventable.validation_events.old_records.destroy_all
|
||||
end
|
||||
|
||||
def check_email(parsed_email)
|
||||
Truemail.validate(parsed_email, with: calculate_check_level).result
|
||||
end
|
||||
|
@ -53,14 +48,10 @@ module Actions
|
|||
|
||||
if !result.success && @check_level == 'mx'
|
||||
result_validation = Actions::AAndAaaaEmailValidation.call(email: @email, value: 'A')
|
||||
output_a_and_aaaa_validation_results(email: @email,
|
||||
result: result_validation,
|
||||
type: 'A')
|
||||
output_a_and_aaaa_validation_results(email: @email, result: result_validation, type: 'A')
|
||||
|
||||
result_validation = Actions::AAndAaaaEmailValidation.call(email: @email, value: 'AAAA') if result_validation.empty?
|
||||
output_a_and_aaaa_validation_results(email: @email,
|
||||
result: result_validation,
|
||||
type: 'AAAA')
|
||||
output_a_and_aaaa_validation_results(email: @email, result: result_validation, type: 'AAAA')
|
||||
result.success = result_validation.present?
|
||||
end
|
||||
|
||||
|
|
|
@ -20,10 +20,6 @@ class VerifyEmailsJob < ApplicationJob
|
|||
|
||||
private
|
||||
|
||||
def contact_not_found(contact_id)
|
||||
raise StandardError, "Contact with contact_id #{contact_id} not found"
|
||||
end
|
||||
|
||||
def validate_check_level(check_level)
|
||||
return if valid_check_levels.include? check_level
|
||||
|
||||
|
@ -38,10 +34,6 @@ class VerifyEmailsJob < ApplicationJob
|
|||
ValidationEvent::VALID_CHECK_LEVELS
|
||||
end
|
||||
|
||||
def get_validation_results(contact)
|
||||
ValidationEvent.where(created_at: Time.zone.now.beginning_of_day..Time.zone.now.end_of_day)
|
||||
end
|
||||
|
||||
def filter_check_level(contact)
|
||||
return true unless contact.validation_events.exists?
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue