|
@@ -5,21 +5,34 @@ module Blazer
|
|
|
validates :query_id, presence: true
|
|
|
|
|
|
def split_emails
|
|
|
- emails.to_s.split(",").map(&:strip)
|
|
|
+ emails.to_s.downcase.split(",").map(&:strip)
|
|
|
end
|
|
|
|
|
|
def update_state(rows, error)
|
|
|
- invert = self.respond_to?(:invert) && self.invert
|
|
|
+ invert = respond_to?(:invert) && self.invert
|
|
|
self.state =
|
|
|
if error
|
|
|
- "error"
|
|
|
+ if error == Blazer::TIMEOUT_MESSAGE
|
|
|
+ "timed out"
|
|
|
+ else
|
|
|
+ "error"
|
|
|
+ end
|
|
|
elsif rows.any?
|
|
|
invert ? "passing" : "failing"
|
|
|
else
|
|
|
invert ? "failing" : "passing"
|
|
|
end
|
|
|
|
|
|
- self.last_run_at = Time.now if self.respond_to?(:last_run_at=)
|
|
|
+ self.last_run_at = Time.now if respond_to?(:last_run_at=)
|
|
|
+
|
|
|
+ if respond_to?(:timeouts=)
|
|
|
+ if state == "timed out"
|
|
|
+ self.timeouts += 1
|
|
|
+ self.state = "disabled" if timeouts >= 3
|
|
|
+ else
|
|
|
+ self.timeouts = 0
|
|
|
+ end
|
|
|
+ end
|
|
|
|
|
|
# do not notify on creation, except when not passing
|
|
|
if (state_was || state != "passing") && state != state_was && emails.present?
|