Add a rake task running job & test for job

This commit is contained in:
Alex Sherman 2021-07-01 16:00:35 +05:00
parent e110924968
commit 5f0c031410
8 changed files with 92 additions and 105 deletions

View file

@ -6,11 +6,20 @@
# For email_validation event kind also check_level (regex/mx/smtp) is stored in the event_data
class ValidationEvent < ApplicationRecord
enum event_type: ValidationEvent::EventType::TYPES, _suffix: true
VALIDATION_PERIOD = 1.month.ago.freeze
store_accessor :event_data, :errors, :check_level, :email
belongs_to :validation_eventable, polymorphic: true
scope :recent, -> { where('created_at > ?', VALIDATION_PERIOD) }
scope :successful, -> { where(success: true) }
def self.validated_ids_by(klass)
recent.successful.where('validation_eventable_type = ?', klass)
.pluck(:validation_eventable_id)
end
def event_type
@event_type ||= ValidationEvent::EventType.new(self[:event_kind])
end