tangled
alpha
login
or
join now
mackuba.eu
/
pulsar
9
fork
atom
A tool for measuring the coverage of Bluesky/ATProto relays
9
fork
atom
overview
issues
pulls
pipelines
show last reports in a table on index
mackuba.eu
1 week ago
9ddf193a
5e74ba5f
+37
-1
3 changed files
expand all
collapse all
unified
split
.gitignore
server.rb
views
index.erb
+1
-1
.gitignore
···
1
config/sources.yml
2
-
db/*.sqlite3
···
1
config/sources.yml
2
+
db/*.sqlite3*
+10
server.rb
···
2
3
require 'bundler/setup'
4
require 'sinatra'
0
5
require 'thin'
0
0
6
7
get '/' do
0
0
0
0
0
0
0
8
erb :index
9
end
···
2
3
require 'bundler/setup'
4
require 'sinatra'
5
+
require 'sinatra/activerecord'
6
require 'thin'
7
+
8
+
require_relative 'report'
9
10
get '/' do
11
+
@last_test = Report.maximum(:start_time)
12
+
13
+
if @last_test
14
+
@reports = Report.where(start_time: @last_test).order('users DESC').to_a
15
+
@max_users = @reports.first.users
16
+
end
17
+
18
erb :index
19
end
+26
views/index.erb
···
1
<h1>Pulsar</h1>
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
···
1
<h1>Pulsar</h1>
2
+
3
+
<% if @last_test %>
4
+
<p>Last observation time: <%= @last_test %></p>
5
+
6
+
<table border>
7
+
<tr>
8
+
<th>Host</th>
9
+
<th>Users</th>
10
+
<th>Events</th>
11
+
<th>% of max</th>
12
+
</tr>
13
+
14
+
<% @reports.each do |report| %>
15
+
<% percent = (@max_users > 0) ? (report.users * 100.0 / @max_users) : 0 %>
16
+
17
+
<tr>
18
+
<td><%= report.host %></td>
19
+
<td><%= report.users %></td>
20
+
<td><%= report.events %></td>
21
+
<td><%= format('%.1f%%', percent) %></td>
22
+
</tr>
23
+
<% end %>
24
+
</table>
25
+
<% else %>
26
+
<p>No observations recorded.</p>
27
+
<% end %>