Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions app/models/ping.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ class Ping < ApplicationRecord
validates(:status, presence: true)
validates(:response_time, presence: true)

default_scope { order(created_at: :desc) }

after_create(:send_to_ping_notifier, unless: :skip_callbacks)

def self.without_outliers
Expand Down
2 changes: 1 addition & 1 deletion app/models/website.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class Website < ApplicationRecord
VALID_URL_REGEX = /\A#{URI::regexp(['http', 'https'])}\z/

has_many :pings, dependent: :delete_all
has_many :recent_pings, -> { limit(5) }, class_name: 'Ping'
has_many :recent_pings, -> { order(created_at: :desc).limit(5) }, class_name: 'Ping'
has_many :daily_pings, -> { limit(1_440) }, class_name: 'Ping'

# Only query the max number from pagination.
Expand Down
4 changes: 2 additions & 2 deletions app/services/notifiers/ping_notifier.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ def can_notify?
end

def first_ping
@first_ping ||= previous_ping.nil?
previous_ping.nil?
end

def previous_ping
website.pings.second
@previous_ping ||= website.pings.order(created_at: :desc).second
end

def message
Expand Down