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")
|
||||
|
||||
get '/' do
|
||||
@down_everage = Rate.average_download
|
||||
@up_everage = Rate.average_upload
|
||||
@data = [
|
||||
{
|
||||
'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] }
|
||||
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
|
||||
|
@ -6,4 +6,9 @@ body {
|
||||
|
||||
h1 {
|
||||
text-align: center !important;
|
||||
}
|
||||
|
||||
.everage {
|
||||
text-align: center;
|
||||
margin-bottom: 13px;
|
||||
}
|
@ -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>
|
Loading…
Reference in New Issue
Block a user