Sha256: 00d7b88eae90d62bbb5de5893b64b0b29721b36dda89b8f6b041fb66b6cbb2df
Contents?: true
Size: 1.17 KB
Versions: 9
Compression:
Stored size: 1.17 KB
Contents
## ## 2023-03-04 _vp_ An instance of an EmailAction. ## class Office::ScheduledEmailAction include Mongoid::Document include Mongoid::Timestamps include Mongoid::Paranoia field :lead_id, type: :integer def lead Lead.find( lead_id ) end STATE_ACTIVE = 'active' STATE_INACTIVE = 'inactive' STATES = [ STATE_ACTIVE, STATE_INACTIVE ] field :state, type: :string scope :active, ->{ where( state: STATE_ACTIVE ) } belongs_to :email_action, class_name: '::Office::EmailAction' has_many :email_contexts, class_name: '::Ish::EmailContext' field :perform_at, type: :timestamp end ::Sch = Office::ScheduledEmailAction ## @TODO: herehere 2023-03-04 _vp_ Currently Working on this =begin ::Sch.active.where( :perform_at.lte => Time.now ) do |sch| next_a = sch.next_email_action if sch.next_actions.present? sch.next_actions.each do |next_a| next_sch_a = ::Office::ScheduledEmailAction.new({ email_action: next_a next_time = Time.now + eval( sch.next_in_days ) next_time.time = eval( sch.next_at_time ) sch.update_attribute( :perform_at, next_time ) end else sch.update_attribute( state: STATE_INACTIVE ) end =end
Version data entries
9 entries across 9 versions & 1 rubygems