diff options
| author | mo khan <mo@mokhan.ca> | 2015-02-04 22:40:04 -0700 |
|---|---|---|
| committer | mo khan <mo@mokhan.ca> | 2015-02-04 22:40:04 -0700 |
| commit | f294743a2de4d8c237e7c520f2ebb0a7218f6710 (patch) | |
| tree | e5be488af820f6bf097a9e94d96e1e21c0a2c029 | |
| parent | 35b088753ffc2ed82071cf7e0c6538b2b47f9e92 (diff) | |
add charts.
| -rw-r--r-- | Gemfile | 2 | ||||
| -rw-r--r-- | Gemfile.lock | 5 | ||||
| -rw-r--r-- | app/controllers/agents/events_controller.rb | 2 | ||||
| -rw-r--r-- | app/views/agents/events/index.html.erb | 10 | ||||
| -rw-r--r-- | app/views/layouts/application.html.erb | 1 |
5 files changed, 19 insertions, 1 deletions
@@ -37,6 +37,8 @@ gem 'bunny' gem 'sneakers' gem 'foreman' gem 'foundation-rails' +gem 'chartkick' +gem 'groupdate' group :development, :test do # Call 'byebug' anywhere in the code to stop execution and get a debugger console diff --git a/Gemfile.lock b/Gemfile.lock index cb96b48..7ad24ad 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -49,6 +49,7 @@ GEM slop (~> 3.6) celluloid (0.16.0) timers (~> 4.0.0) + chartkick (1.3.2) coffee-rails (4.1.0) coffee-script (>= 2.2.0) railties (>= 4.0.0, < 5.0) @@ -73,6 +74,8 @@ GEM sass (>= 3.3.0, < 3.5) globalid (0.3.0) activesupport (>= 4.1.0) + groupdate (2.4.0) + activesupport (>= 3) hike (1.2.3) hitimes (1.2.2) i18n (0.7.0) @@ -187,9 +190,11 @@ PLATFORMS DEPENDENCIES bunny byebug + chartkick coffee-rails (~> 4.1.0) foreman foundation-rails + groupdate jbuilder (~> 2.0) jquery-rails listen diff --git a/app/controllers/agents/events_controller.rb b/app/controllers/agents/events_controller.rb index 630f4df..33dcb7f 100644 --- a/app/controllers/agents/events_controller.rb +++ b/app/controllers/agents/events_controller.rb @@ -3,7 +3,7 @@ module Agents before_action :load_agent def index - @events = Event.all.order(created_at: :desc) + @events = @agent.events.order(created_at: :desc) end def new diff --git a/app/views/agents/events/index.html.erb b/app/views/agents/events/index.html.erb index fb7afc9..6143c15 100644 --- a/app/views/agents/events/index.html.erb +++ b/app/views/agents/events/index.html.erb @@ -31,4 +31,14 @@ </tbody> </table> </div> + + <div class="small-12 columns"> + <h2>Events per minute</h2> + <%= line_chart @agent.events.group_by_minute(:created_at).count %> + </div> + + <div class="small-12 columns"> + <h2>Events by category</h2> + <%= pie_chart @agent.events.group(:name).count %> + </div> </div> diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 00fb7fa..5031340 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -9,6 +9,7 @@ <%= stylesheet_link_tag "application" %> <%= javascript_include_tag "vendor/modernizr" %> <%= javascript_include_tag "application", 'data-turbolinks-track' => true %> + <%= javascript_include_tag "//www.google.com/jsapi", "chartkick" %> <%= csrf_meta_tags %> </head> |
