From 2a0c030d16396f0986b949f8e80fdd63395a876e Mon Sep 17 00:00:00 2001 From: Luiz Picolo Date: Tue, 2 Nov 2021 22:45:01 -0400 Subject: [PATCH] refactored charts --- app.rb | 26 +++++++++----------------- views/home.erb | 18 ++---------------- 2 files changed, 11 insertions(+), 33 deletions(-) diff --git a/app.rb b/app.rb index b0eb111..c6fe0a8 100644 --- a/app.rb +++ b/app.rb @@ -8,23 +8,15 @@ set :database_file, 'config/database.yml' Time.now.utc.localtime("-04:00") get '/' do - @down_everage = Rate.average(:download) - @up_everage = Rate.average(:upload) - - @max_download = Rate.extremes(:maximum, :download) - @min_download = Rate.extremes(:minimum, :download) - @max_upload = Rate.extremes(:maximum, :upload) - @min_upload = Rate.extremes(:minimum, :upload) - - @data = [ - { - 'name': 'Download Rate', - 'data': Rate.transfer('download') - }, - { - 'name': 'Upload Rate', - 'data': Rate.transfer('upload') - }, + @transfer_rate = [ + {'name': 'Download Rate', 'data': Rate.transfer('download')}, + {'name': 'Upload Rate', 'data': Rate.transfer('upload')} + ] + + @download_rate = [ + {'name': 'Max Download Rate', 'data': Rate.extremes(:maximum, :download)}, + {'name': 'Min Download Rate', 'data': Rate.extremes(:minimum, :download)}, + {'name': 'Everage Download Rate', 'data': Rate.extremes(:average, :download)} ] erb :home diff --git a/views/home.erb b/views/home.erb index 789bdc2..85c9061 100644 --- a/views/home.erb +++ b/views/home.erb @@ -1,17 +1,3 @@

Data Transfer Test

-
-

Everage:

- Download: <%= @down_everage %> Mbps - Upload: <%= @up_everage %> Mbps -
-
-

Maximum:

- Download: <%= @max_download %> Mbps - Upload: <%= @max_upload %> Mbps -
-
-

Minimum:

- Download: <%= @min_download %> Mbps - Upload: <%= @min_upload %> Mbps -
-<%= bar_chart @data, xtitle: "Datetime", ytitle: "Rate", id: "users-chart", height: "700px" %> \ No newline at end of file +<%= bar_chart @transfer_rate, xtitle: "Rate", ytitle: "Datetime", id: "rate_transfer-chart", height: "700px" %> +<%= column_chart @download_rate, xtitle: "Datetime", ytitle: "Rate", id: "download_rate-chart", height: "700px" %> \ No newline at end of file