Added last value

This commit is contained in:
Luiz F Picolo 2023-09-09 19:08:04 -04:00
parent 01f0527a06
commit c8c11e1e39
3 changed files with 19 additions and 0 deletions

View File

@ -21,6 +21,14 @@ class Rate < ActiveRecord::Base
where(created_at: Date.today.all_day)
end
def self.last_time
self.transfer('download').last.first
end
def self.last_value(type)
self.transfer(type).last.last
end
def self.save
test = Speedtest::Test.new(debug: false)
result = test.run

View File

@ -22,4 +22,8 @@ section {
canvas {
margin-top: 15px;
}
.lastcheck {
margin-right: 20px !important;
}

View File

@ -1,5 +1,12 @@
<div class="container">
<h1>Data Transfer Test</h1>
<div class="text-center">
<h2>Last Check</h2>
<div><%= Rate.last_time %></div>
Download: <%= Rate.last_value('download') %>
Upload: <%= Rate.last_value('upload') %>
</div>
<br />
<div class="row row-cols-1 row-cols-sm-1 row-cols-md-3">
<div class="col">
<h2 class="text-center">Transfer Rate</h2>