Added last value
This commit is contained in:
parent
01f0527a06
commit
c8c11e1e39
@ -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
|
||||
|
@ -22,4 +22,8 @@ section {
|
||||
|
||||
canvas {
|
||||
margin-top: 15px;
|
||||
}
|
||||
|
||||
.lastcheck {
|
||||
margin-right: 20px !important;
|
||||
}
|
@ -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>
|
||||
|
Loading…
Reference in New Issue
Block a user