A tool for measuring the coverage of Bluesky/ATProto relays
1require_relative 'report'
2
3class TestRun < ActiveRecord::Base
4 validates_presence_of :start_time, :duration
5
6 has_many :reports, dependent: :delete_all
7
8 def calculate_max_users
9 user_counts = self.reports.order('users').map(&:users)
10
11 if user_counts.length >= 3
12 median = user_counts[user_counts.length / 2]
13 user_counts.select { |x| x <= median * 1.1 }.last
14 else
15 user_counts.last
16 end
17 end
18
19 def update_max_users
20 self.update!(max_users: calculate_max_users)
21 end
22end