A tool for measuring the coverage of Bluesky/ATProto relays
9
fork

Configure Feed

Select the types of activity you want to include in your feed.

store max_users in a separate table column

+33 -10
+13
db/migrate/20260414220141_add_max_users.rb
··· 1 + require_relative '../../test_run' 2 + 3 + class AddMaxUsers < ActiveRecord::Migration[7.2] 4 + def up 5 + add_column :test_runs, :max_users, :integer, null: true 6 + 7 + TestRun.all.each(&:update_max_users) 8 + end 9 + 10 + def down 11 + remove_column :test_runs, :max_users 12 + end 13 + end
+2 -1
db/schema.rb
··· 10 10 # 11 11 # It's strongly recommended that you check this file into your version control system. 12 12 13 - ActiveRecord::Schema[7.2].define(version: 2026_04_14_212524) do 13 + ActiveRecord::Schema[7.2].define(version: 2026_04_14_220141) do 14 14 create_table "reports", force: :cascade do |t| 15 15 t.string "host", null: false 16 16 t.integer "users", null: false ··· 26 26 create_table "test_runs", force: :cascade do |t| 27 27 t.datetime "start_time", precision: 0, null: false 28 28 t.integer "duration", null: false 29 + t.integer "max_users" 29 30 t.index ["start_time"], name: "index_test_runs_on_start_time" 30 31 end 31 32 end
+2
run_test.rb
··· 117 117 ) 118 118 end 119 119 end 120 + 121 + test&.update_max_users 120 122 rescue Interrupt 121 123 puts 122 124 puts "Stopping..."
-8
server.rb
··· 38 38 39 39 if @last_test 40 40 @reports = @last_test.reports.order('users DESC, connected DESC').to_a 41 - 42 - if @reports.length >= 3 43 - middle = @reports.length / 2 44 - median = @reports.reverse.map(&:users)[middle] 45 - @max_users = @reports.select { |x| x.users <= median * 1.1 }.first.users 46 - else 47 - @max_users = @reports.first.users 48 - end 49 41 end 50 42 51 43 erb :index
+15
test_run.rb
··· 4 4 validates_presence_of :start_time, :duration 5 5 6 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 7 22 end
+1 -1
views/index.erb
··· 17 17 </tr> 18 18 19 19 <% @reports.each do |report| %> 20 - <% percent = (@max_users > 0) ? (report.users * 100.0 / @max_users) : 0 %> 20 + <% percent = (@last_test.max_users.to_i > 0) ? (report.users * 100.0 / @last_test.max_users) : 0 %> 21 21 22 22 <tr> 23 23 <td><a href="https://<%= report.host %>" target="_blank"><%= report.host %><a></td>