Module: Forcast::Model::RuleEngine::WebhookEngine
- Extended by:
- ActiveSupport::Concern
- Included in:
- Webhook
- Defined in:
- lib/forcast/models/rule_engine/webhook_engine.rb
Instance Method Summary collapse
Instance Method Details
#validate_duration_time ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/forcast/models/rule_engine/webhook_engine.rb', line 12 def validate_duration_time puts "validate_duration_time" return true if self.rule.class_rule? if self.forever_true? puts "Forever True Duration" return true end webhook_duration_time = self.duration_time webhook_duration_time ||= 1 testing_time = self.created_at + webhook_duration_time.minutes if testing_time.to_i < Time.now.to_i self.update_columns(:active? => false) puts "Duration period expire" return false else puts "Duration period still active" return true end end |
#validate_send_time ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/forcast/models/rule_engine/webhook_engine.rb', line 32 def validate_send_time puts "validate_send_time" send_time = self.send_time send_time ||= 30 last_review_send = self.last_review_send last_review_send ||= Time.now testing_time = last_review_send + send_time.second remain = testing_time.to_i - Time.now.to_i if testing_time.to_i > Time.now.to_i puts "Dont send yet, remains #{remain} seconds" self.update_columns( :last_review_send => Time.now, :send? => false) return false else puts "Send now" self.update_columns(:last_send => Time.now, :send? => true) return true end end |