Something went wrong. Try again.
A tool for measuring the coverage of Bluesky/ATProto relays forked from mackuba.eu/pulsar
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546class Report < ActiveRecord::Base enum :source_type, { jetstream: 'jetstream', firehose: 'firehose' }
validates_presence_of :host, :users, :events, :source_type belongs_to :test_runend
class TestRun < ActiveRecord::Base validates_presence_of :start_time, :duration
has_many :reports, dependent: :delete_all
def calculate_max_users user_counts = self.reports.sort_by(&:users).map(&:users)
if user_counts.length >= 4 median = user_counts[(user_counts.length * 0.75).floor.to_i] user_counts.select { |x| x <= median * 1.01 }.last else user_counts.last end end
def update_max_users self.update!(max_users: calculate_max_users) endend
class Ping < ActiveRecord::Base validates_presence_of :time, :host
def self.current_uptimes ok_query = Ping.select('host, CASE WHEN connected = TRUE AND got_message = TRUE AND got_error = FALSE THEN 1 ELSE 0 END AS ok') .where('time > ?', Time.now - 86400 * 30)
Ping.select('host, AVG(ok) AS average') .from("(#{ok_query.to_sql}) AS ok_pings") .group('host') .map { |x| [x.host, x.average] } .to_h endend