Added evarage down and up

This commit is contained in:
Luiz F Picolo 2021-10-08 23:18:03 -04:00
parent 0d9cb95f6b
commit 9280d49441
4 changed files with 19 additions and 0 deletions

2
app.rb
View File

@ -8,6 +8,8 @@ set :database_file, 'config/database.yml'
Time.now.utc.localtime("-04:00")
get '/' do
@down_everage = Rate.average_download
@up_everage = Rate.average_upload
@data = [
{
'name': 'Download Rate',

View File

@ -13,6 +13,14 @@ class Rate < ActiveRecord::Base
where(created_at: Date.today.all_day).collect { |p| [p.created_at.strftime('%d/%m %H:%M'), p.upload] }
end
def self.average_download
average(:download).ceil(2)
end
def self.average_upload
average(:upload).ceil(2)
end
def self.save
test = Speedtest::Test.new(debug: false)
result = test.run

View File

@ -6,4 +6,9 @@ body {
h1 {
text-align: center !important;
}
.everage {
text-align: center;
margin-bottom: 13px;
}

View File

@ -13,6 +13,10 @@
</head>
<body>
<h1>Data Transfer Test</h1>
<div class="everage">
<b>Download:</b> <%= @down_everage %>
<b>Upload:</b> <%= @up_everage %>
</div>
<%= yield %>
</body>
</html>