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) where(created_at: Date.today.all_day)
end 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 def self.save
test = Speedtest::Test.new(debug: false) test = Speedtest::Test.new(debug: false)
result = test.run result = test.run

View File

@ -23,3 +23,7 @@ section {
canvas { canvas {
margin-top: 15px; margin-top: 15px;
} }
.lastcheck {
margin-right: 20px !important;
}

View File

@ -1,5 +1,12 @@
<div class="container"> <div class="container">
<h1>Data Transfer Test</h1> <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="row row-cols-1 row-cols-sm-1 row-cols-md-3">
<div class="col"> <div class="col">
<h2 class="text-center">Transfer Rate</h2> <h2 class="text-center">Transfer Rate</h2>