Added evarage down and up
This commit is contained in:
parent
0d9cb95f6b
commit
9280d49441
2
app.rb
2
app.rb
@ -8,6 +8,8 @@ set :database_file, 'config/database.yml'
|
|||||||
Time.now.utc.localtime("-04:00")
|
Time.now.utc.localtime("-04:00")
|
||||||
|
|
||||||
get '/' do
|
get '/' do
|
||||||
|
@down_everage = Rate.average_download
|
||||||
|
@up_everage = Rate.average_upload
|
||||||
@data = [
|
@data = [
|
||||||
{
|
{
|
||||||
'name': 'Download Rate',
|
'name': 'Download Rate',
|
||||||
|
@ -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] }
|
where(created_at: Date.today.all_day).collect { |p| [p.created_at.strftime('%d/%m %H:%M'), p.upload] }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.average_download
|
||||||
|
average(:download).ceil(2)
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.average_upload
|
||||||
|
average(:upload).ceil(2)
|
||||||
|
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
|
||||||
|
@ -7,3 +7,8 @@ body {
|
|||||||
h1 {
|
h1 {
|
||||||
text-align: center !important;
|
text-align: center !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.everage {
|
||||||
|
text-align: center;
|
||||||
|
margin-bottom: 13px;
|
||||||
|
}
|
@ -13,6 +13,10 @@
|
|||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<h1>Data Transfer Test</h1>
|
<h1>Data Transfer Test</h1>
|
||||||
|
<div class="everage">
|
||||||
|
<b>Download:</b> <%= @down_everage %>
|
||||||
|
<b>Upload:</b> <%= @up_everage %>
|
||||||
|
</div>
|
||||||
<%= yield %>
|
<%= yield %>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
Loading…
Reference in New Issue
Block a user