diff --git a/app/controllers/checks_controller.rb b/app/controllers/checks_controller.rb index fff3482..7610ab3 100644 --- a/app/controllers/checks_controller.rb +++ b/app/controllers/checks_controller.rb @@ -6,6 +6,7 @@ class ChecksController < ApplicationController has_scope :kind has_scope :by_domain + has_scope :recurrent_failures, type: :boolean def index @checks = apply_scopes(policy_scope(Check)).order(current_sort).page(params[:page]) diff --git a/app/models/check.rb b/app/models/check.rb index 6d214a6..a54def2 100644 --- a/app/models/check.rb +++ b/app/models/check.rb @@ -60,6 +60,10 @@ class Check < ApplicationRecord scope :kind, ->(kind) { where(kind: kind) } scope :by_domain, ->(domain) { where("domain LIKE ?", "%#{domain}%") } + scope :recurrent_failures, -> { + where("last_run_at IS NOT NULL"). + where("last_success_at IS NULL OR last_success_at <= DATE_SUB(last_run_at, INTERVAL 72 HOUR)") + } def self.default_sort { domain_expires_at: :asc } diff --git a/app/views/checks/index.html.erb b/app/views/checks/index.html.erb index 606ee1f..b6ce6b3 100644 --- a/app/views/checks/index.html.erb +++ b/app/views/checks/index.html.erb @@ -9,6 +9,7 @@