|
@@ -16,6 +16,9 @@ class Event < ActiveRecord::Base
|
|
belongs_to :user
|
|
belongs_to :user
|
|
belongs_to :agent, :counter_cache => true, :touch => :last_event_at
|
|
belongs_to :agent, :counter_cache => true, :touch => :last_event_at
|
|
|
|
|
|
|
|
+ has_many :agent_logs_as_inbound_event, :class_name => "AgentLog", :foreign_key => :inbound_event_id, :dependent => :nullify
|
|
|
|
+ has_many :agent_logs_as_outbound_event, :class_name => "AgentLog", :foreign_key => :outbound_event_id, :dependent => :nullify
|
|
|
|
+
|
|
scope :recent, lambda { |timespan = 12.hours.ago|
|
|
scope :recent, lambda { |timespan = 12.hours.ago|
|
|
where("events.created_at > ?", timespan)
|
|
where("events.created_at > ?", timespan)
|
|
}
|
|
}
|
|
@@ -36,6 +39,7 @@ class Event < ActiveRecord::Base
|
|
end
|
|
end
|
|
|
|
|
|
protected
|
|
protected
|
|
|
|
+
|
|
def possibly_propagate
|
|
def possibly_propagate
|
|
#immediately schedule agents that want immediate updates
|
|
#immediately schedule agents that want immediate updates
|
|
propagate_ids = agent.receivers.where(:propagate_immediately => true).pluck(:id)
|
|
propagate_ids = agent.receivers.where(:propagate_immediately => true).pluck(:id)
|