best_boy 2.2.3 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (59) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +74 -110
  3. data/app/assets/javascripts/best_boy/best_boy.js +0 -1
  4. data/app/assets/stylesheets/best_boy/base.sass +21 -0
  5. data/app/assets/stylesheets/best_boy/best_boy.css +1 -3
  6. data/app/controllers/best_boy/{best_boy_events_controller.rb → events_controller.rb} +4 -4
  7. data/{lib/best_boy/models/active_record → app/models}/best_boy/day_report.rb +0 -0
  8. data/app/models/best_boy/event.rb +29 -0
  9. data/{lib/best_boy/models/active_record → app/models}/best_boy/month_report.rb +0 -0
  10. data/app/views/best_boy/events/_navigation.html.erb +11 -0
  11. data/app/views/best_boy/events/charts.html.erb +33 -0
  12. data/app/views/best_boy/events/details.html.erb +98 -0
  13. data/app/views/best_boy/events/details.xml.haml +22 -0
  14. data/app/views/best_boy/events/index.html.erb +8 -0
  15. data/app/views/best_boy/events/lists.html.erb +62 -0
  16. data/app/views/best_boy/events/lists.xml.haml +8 -0
  17. data/app/views/best_boy/events/monthly_details.html.erb +67 -0
  18. data/app/views/best_boy/events/monthly_details.xml.haml +15 -0
  19. data/app/views/best_boy/events/stats.html.erb +89 -0
  20. data/app/views/best_boy/events/stats.xml.haml +18 -0
  21. data/app/views/layouts/best_boy/best_boy.html.erb +43 -0
  22. data/config/routes.rb +13 -7
  23. data/db/migrate/20150610155237_create_best_boy_events.rb +17 -0
  24. data/db/migrate/20150610155251_create_best_boy_reports.rb +28 -0
  25. data/lib/best_boy.rb +8 -5
  26. data/lib/best_boy/{controllers/best_boy_controller.rb → controller.rb} +6 -3
  27. data/lib/best_boy/engine.rb +7 -27
  28. data/lib/best_boy/{models/active_record/best_boy/eventable.rb → eventable.rb} +7 -6
  29. data/lib/best_boy/{models/active_record/best_boy/obeys_test_mode.rb → obeys_test_mode.rb} +0 -0
  30. data/lib/best_boy/{models/active_record/best_boy/reporting.rb → reporting.rb} +0 -0
  31. data/lib/best_boy/version.rb +1 -1
  32. data/lib/generators/best_boy/install_generator.rb +11 -0
  33. data/lib/generators/{templates → best_boy/templates/config/initializers}/best_boy.rb +0 -6
  34. data/lib/tasks/recover_report_history.rake +7 -7
  35. metadata +64 -71
  36. data/app/assets/images/best_boy/glyphicons-halflings-white.png +0 -0
  37. data/app/assets/images/best_boy/glyphicons-halflings.png +0 -0
  38. data/app/assets/javascripts/best_boy/bootstrap_datepicker.js +0 -401
  39. data/app/assets/stylesheets/best_boy/bootstrap.scss +0 -4983
  40. data/app/assets/stylesheets/best_boy/bootstrap_datepicker.css +0 -156
  41. data/app/views/best_boy/best_boy_events/_navigation.html.erb +0 -9
  42. data/app/views/best_boy/best_boy_events/charts.html.erb +0 -25
  43. data/app/views/best_boy/best_boy_events/details.html.erb +0 -88
  44. data/app/views/best_boy/best_boy_events/index.html.erb +0 -6
  45. data/app/views/best_boy/best_boy_events/lists.html.erb +0 -45
  46. data/app/views/best_boy/best_boy_events/monthly_details.html.erb +0 -51
  47. data/app/views/best_boy/best_boy_events/stats.html.erb +0 -80
  48. data/app/views/layouts/best_boy_backend.html.erb +0 -70
  49. data/lib/best_boy/models/active_record/best_boy_event.rb +0 -21
  50. data/lib/generators/active_record/best_boy_generator.rb +0 -29
  51. data/lib/generators/active_record/templates/add_event_source_to_best_boy_events_table.rb +0 -11
  52. data/lib/generators/active_record/templates/create_best_boy_events_table.rb +0 -17
  53. data/lib/generators/active_record/templates/create_best_boy_reports.rb +0 -30
  54. data/lib/generators/best_boy_generator.rb +0 -23
  55. data/lib/generators/templates/bootstrap/bootstrap.css +0 -4983
  56. data/lib/generators/templates/bootstrap/bootstrap_datepicker.css +0 -156
  57. data/lib/generators/templates/bootstrap/bootstrap_datepicker.js +0 -401
  58. data/lib/generators/templates/bootstrap/glyphicons-halflings-white.png +0 -0
  59. data/lib/generators/templates/bootstrap/glyphicons-halflings.png +0 -0
@@ -0,0 +1,22 @@
1
+ !!! XML
2
+ %details
3
+ %events
4
+ %owner_type= current_owner_type
5
+ %name= current_event
6
+ %year= current_year
7
+ - if available_event_sources?
8
+ %event_sources
9
+ - @event_selected_year_occurrences.keys.reject { |k| k == "All" }.each do |source|
10
+ %event_source
11
+ %name= source
12
+ %months
13
+ - @event_selected_year_occurrences[source].keys.reject.each do |month|
14
+ %month
15
+ %number= month
16
+ %count= @event_selected_year_occurrences[source][month]
17
+ %totals
18
+ %months
19
+ - @event_selected_year_occurrences["All"].keys.each do |month|
20
+ %month
21
+ %number= month
22
+ %count= @event_selected_year_occurrences["All"][month]
@@ -0,0 +1,8 @@
1
+ <div class="row">
2
+ <div class="col-md-12">
3
+ <div class="jumbotron">
4
+ <h2>BestBoy Administration Center</h2>
5
+ <p>BestBoy provides several statistics and logs for you. You can access yearly, monthly, weekly and day statistics for your logged events per owner class. In the list and logs section you can see realtime events and search for date and events for each owner class.</p>
6
+ </div>
7
+ </div>
8
+ </div>
@@ -0,0 +1,62 @@
1
+ <% content_for :stylesheets do %>
2
+ <%= stylesheet_link_tag "https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.4.0/css/bootstrap-datepicker.min.css" %>
3
+ <% end %>
4
+ <% content_for :javascripts do %>
5
+ <%= javascript_include_tag "https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" %>
6
+ <%= javascript_include_tag "https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.4.0/js/bootstrap-datepicker.min.js" %>
7
+ <script type="text/javascript">
8
+ $(function(){$('#dp1').datepicker().on('changeDate', function(){$('#list-form').submit();})});
9
+ </script>
10
+ <% end %>
11
+
12
+ <%= render "navigation", referrer: "lists" %>
13
+
14
+ <div class="row">
15
+ <div class="col-md-12">
16
+ <div class="well">
17
+ <div class="row">
18
+ <div class="col-md-7">
19
+ <h3>Log</h3>
20
+ </div>
21
+ <div class="col-md-5">
22
+ <%= form_tag lists_events_path, method: :get, id: "list-form" do %>
23
+ <div class="form-group">
24
+ <div class="col-md-6">
25
+ <div class="input-group date" id="dp1" data-date="<%= params[:date].present? ? params[:date] : l(Time.zone.now, format: "%d-%m-%Y") %>" data-date-format="dd-mm-yyyy">
26
+ <input name="date" class="form-control" type="text" value="<%= params[:date] %>" readonly="readonly">
27
+ <span class="input-group-addon"><i class="glyphicon glyphicon-th"></i></span>
28
+ </div>
29
+ </div>
30
+ <%= hidden_field_tag :owner_type, current_owner_type %>
31
+ <div class="col-md-6">
32
+ <%= select_tag :event, options_for_select([["all Events", nil]] + available_events, selected: current_event), onchange: "submit();", class: "form-control" %>
33
+ </div>
34
+ </div>
35
+ <% end %>
36
+ </div>
37
+ </div>
38
+
39
+ <table class="table table-striped table-bordered">
40
+ <thead>
41
+ <tr>
42
+ <th>Owner Type</th>
43
+ <th>Event</th>
44
+ <th>Event source</th>
45
+ <th>created_at</th>
46
+ </tr>
47
+ </thead>
48
+ <tbody>
49
+ <% collection.each do |best_boy_event| %>
50
+ <tr>
51
+ <td><%= best_boy_event.owner_type %></td>
52
+ <td><%= best_boy_event.event %></td>
53
+ <td><%= best_boy_event.event_source %></td>
54
+ <td><%= best_boy_event.created_at %></td>
55
+ </tr>
56
+ <% end %>
57
+ </tbody>
58
+ </table>
59
+ <%= paginate collection %>
60
+ </div>
61
+ </div>
62
+ </div>
@@ -0,0 +1,8 @@
1
+ !!! XML
2
+ %events
3
+ - collection.each do |event|
4
+ %event
5
+ %owner_type event.owner_type
6
+ %event event.event
7
+ %event_source event.event_source
8
+ %created_at event.created_at.utc
@@ -0,0 +1,67 @@
1
+ <% content_for :javascripts do %>
2
+ <%= javascript_include_tag "https://www.google.com/jsapi" %>
3
+ <% end %>
4
+
5
+ <div class="row">
6
+ <div class="col-md-12">
7
+ <div class="well">
8
+ <%= link_to "<< back to stats", stats_events_path(owner_type: current_owner_type) %>
9
+ </div>
10
+ </div>
11
+ </div>
12
+
13
+ <div class="row">
14
+ <div class="col-md-12">
15
+ <div class="well">
16
+ <div class="row">
17
+ <div class="col-md-8">
18
+ <h3>Detailed Statistics for <%= current_month %> <%= current_year %></h3>
19
+ </div>
20
+ <div class="col-md-4">
21
+ <%= form_tag monthly_details_events_path, method: :get do %>
22
+ <div class="form-group">
23
+ <%= hidden_field_tag :owner_type, current_owner_type %>
24
+ <%= hidden_field_tag :event, current_event %>
25
+ <%= hidden_field_tag :time_interval, "month" %>
26
+ <div class="col-md-6">
27
+ <%= select_tag :month, options_for_select(%w(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec), selected: current_month), onchange: "submit();", class: "form-control" %>
28
+ </div>
29
+ <div class="col-md-6">
30
+ <%= select_tag :year, options_for_select(available_years, selected: current_year), onchange: "submit();", class: "form-control" %>
31
+ </div>
32
+ </div>
33
+ <% end %>
34
+ </div>
35
+ </div>
36
+ <table class="table table-striped table-bordered small-font">
37
+ <thead>
38
+ <tr>
39
+ <th>Event Source</th>
40
+ <% days_of(current_month).each do |day| %>
41
+ <td><%= day.strftime("%d") %></td>
42
+ <% end %>
43
+ </tr>
44
+ </thead>
45
+ <tbody>
46
+ <% @selected_month_occurrences.keys.each do |source| %>
47
+ <tr>
48
+ <td><%= source %></td>
49
+ <% @selected_month_occurrences[source].keys.each do |day| %>
50
+ <td><%= @selected_month_occurrences[source][day] %></td>
51
+ <% end%>
52
+ </tr>
53
+ <% end%>
54
+ </tbody>
55
+ </table>
56
+ </div>
57
+ </div>
58
+ </div>
59
+
60
+ <div class="row">
61
+ <div class="col-md-12">
62
+ <div class="well">
63
+ <div id='chart'></div>
64
+ <%= render_chart @chart, 'chart' %>
65
+ </div>
66
+ </div>
67
+ </div>
@@ -0,0 +1,15 @@
1
+ !!! XML
2
+ %monthly_details
3
+ %events
4
+ %owner_type= current_owner_type
5
+ %name= current_event
6
+ %month= current_year
7
+ %year= current_year
8
+ %event_sources
9
+ - @selected_month_occurrences.keys.each do |source|
10
+ %event= source
11
+ %days
12
+ - @selected_month_occurrences[source].keys.each do |day|
13
+ %day
14
+ %number= day
15
+ %count= @selected_month_occurrences[source][day]
@@ -0,0 +1,89 @@
1
+ <%= render "navigation", referrer: "stats" %>
2
+
3
+ <div class="row">
4
+ <div class="col-md-12">
5
+ <div class="well">
6
+ <h3>Statistics</h3>
7
+ <table class="table table-striped table-bordered">
8
+ <thead>
9
+ <tr>
10
+ <th>Event</th>
11
+ <th>overall</th>
12
+ <th>year</th>
13
+ <th>month</th>
14
+ <th>week</th>
15
+ <th>day</th>
16
+ </tr>
17
+ </thead>
18
+ <tbody>
19
+ <% @occurrences.keys.each do |key| %>
20
+ <tr>
21
+ <td><%= link_to key, details_events_path(event: key, owner_type: current_owner_type) %></td>
22
+ <td><%= @occurrences[key][:overall] %></td>
23
+ <td><%= @occurrences[key][:yearly] %></td>
24
+ <td><%= @occurrences[key][:monthly] %></td>
25
+ <td><%= @occurrences[key][:weekly] %> </td>
26
+ <td><%= @occurrences[key][:daily] %></td>
27
+ </tr>
28
+ <% end %>
29
+ </tbody>
30
+ <tfoot>
31
+ <tr>
32
+ <th>Total</th>
33
+ <th><%= @this_year_totals[:overall] %></th>
34
+ <th><%= @this_year_totals[:yearly] %></th>
35
+ <th><%= @this_year_totals[:monthly] %></th>
36
+ <th><%= @this_year_totals[:weekly] %></th>
37
+ <th><%= @this_year_totals[:daily] %></th>
38
+ </tr>
39
+ </tfoot>
40
+ </table>
41
+ </div>
42
+ </div>
43
+ </div>
44
+
45
+ <div class="row">
46
+ <div class="col-md-12">
47
+ <div class="well">
48
+ <div class="row">
49
+ <div class="col-md-10">
50
+ <h3>Statistics for <%= current_year %> per month</h3>
51
+ </div>
52
+ <div class="col-md-2">
53
+ <%= form_tag stats_events_path, method: :get do %>
54
+ <%= hidden_field_tag :owner_type, current_owner_type %>
55
+ <%= select_tag :year, options_for_select(available_years, selected: current_year), onchange: "submit();", class: "form-control" %>
56
+ <% end %>
57
+ </div>
58
+ </div>
59
+ <table class="table table-striped table-bordered">
60
+ <thead>
61
+ <tr>
62
+ <th>Event</th>
63
+ <% month_name_array.each do |month| %>
64
+ <th><%= month %></th>
65
+ <% end %>
66
+ </tr>
67
+ </thead>
68
+ <tbody>
69
+ <% @selected_year_occurrences.keys.each do |event| %>
70
+ <tr>
71
+ <td><%= event %></td>
72
+ <% @selected_year_occurrences[event].keys.each do |month| %>
73
+ <td><%= @selected_year_occurrences[event][month] %></td>
74
+ <% end %>
75
+ </tr>
76
+ <% end %>
77
+ </tbody>
78
+ <tfoot>
79
+ <tr>
80
+ <th><strong>Total</strong></th>
81
+ <% @selected_year_totals.keys.each do |month| %>
82
+ <th><%= @selected_year_totals[month] %></th>
83
+ <% end %>
84
+ </tr>
85
+ </tfoot>
86
+ </table>
87
+ </div>
88
+ </div>
89
+ </div>
@@ -0,0 +1,18 @@
1
+ !!! XML
2
+ %statistics
3
+ %overall
4
+ - @occurrences.each do |event, count|
5
+ %events
6
+ %event
7
+ %name= event
8
+ %overall= @occurrences[event][:overall]
9
+ %yearly= @occurrences[event][:yearly]
10
+ %monthly= @occurrences[event][:monthly]
11
+ %weekly= @occurrences[event][:weekly]
12
+ %daily= @occurrences[event][:daily]
13
+ %totals
14
+ %overall= @this_year_totals[:overall]
15
+ %yearly= @this_year_totals[:yearly]
16
+ %monthly= @this_year_totals[:monthly]
17
+ %weekly= @this_year_totals[:weekly]
18
+ %daily= @this_year_totals[:daily]
@@ -0,0 +1,43 @@
1
+ <!doctype html>
2
+ <html class="no-js" lang="en">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta name="description" content="">
6
+ <meta name="viewport" content="width=device-width">
7
+ <title>BBAC - BestBoy Administration Center</title>
8
+ <%= csrf_meta_tag %>
9
+ <link href="//netdna.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css" rel="stylesheet"></link>
10
+
11
+ <%= yield :stylesheets %>
12
+ <%= yield :javascripts %>
13
+
14
+ <%= stylesheet_link_tag "best_boy/best_boy", media: "all" %>
15
+ <%= javascript_include_tag "best_boy/best_boy" %>
16
+
17
+ </head>
18
+ <body>
19
+ <div class="navbar navbar-fixed-top navbar-inverse" role="navigation">
20
+ <div class="container">
21
+ <div class="navigation-header">
22
+ <%= link_to "Best Boy", root_path, class: "navbar-brand" %>
23
+ </div>
24
+ <div class="collapse navbar-collapse">
25
+ <ul class="nav navbar-nav">
26
+ <li class="<%= action_name == 'stats' ? 'active' : nil %>"><%= link_to "Statistics", stats_events_path %></li>
27
+ <li class="<%= action_name == 'lists' ? 'active' : nil %>"><%= link_to "List & Logs", lists_events_path %></li>
28
+ <li class="<%= action_name == 'charts' ? 'active' : nil %>"><%= link_to "Charts", charts_events_path %></li>
29
+ </ul>
30
+ <% if BestBoy.custom_redirect.present? %>
31
+ <ul class="nav navbar-nav navbar-right">
32
+ <li><%= link_to "Back to application", BestBoy.custom_redirect %></li>
33
+ </ul>
34
+ <% end %>
35
+ </div>
36
+ </div>
37
+ </div>
38
+
39
+ <div class="container">
40
+ <%= yield %>
41
+ </div>
42
+ </body>
43
+ </html>
@@ -1,8 +1,14 @@
1
- Rails.application.routes.draw do
2
- get "best_boy_admin" => "best_boy/best_boy_events#index", :as => :best_boy_admin
3
- get "best_boy_admin/stats" => "best_boy/best_boy_events#stats", :as => :best_boy_admin_stats
4
- get "best_boy_admin/lists" => "best_boy/best_boy_events#lists", :as => :best_boy_admin_lists
5
- get "best_boy_admin/charts" => "best_boy/best_boy_events#charts", :as => :best_boy_admin_charts
6
- get "best_boy_admin/details" => "best_boy/best_boy_events#details", :as => :best_boy_admin_details
7
- get "best_boy_admin/monthly_details" => "best_boy/best_boy_events#monthly_details", :as => :best_boy_admin_monthly_details
1
+ BestBoy::Engine.routes.draw do
2
+
3
+ root to: "events#index"
4
+
5
+ resources :events, only: [:index] do
6
+ collection do
7
+ get :stats
8
+ get :lists
9
+ get :charts
10
+ get :details
11
+ get :monthly_details
12
+ end
13
+ end
8
14
  end
@@ -0,0 +1,17 @@
1
+ class CreateBestBoyEvents < ActiveRecord::Migration
2
+ def change
3
+ create_table :best_boy_events do |t|
4
+ t.integer :owner_id
5
+ t.string :owner_type
6
+ t.string :event
7
+ t.string :event_source
8
+ t.timestamps
9
+ end
10
+
11
+ add_index :best_boy_events, :event
12
+ add_index :best_boy_events, :event_source
13
+ add_index :best_boy_events, [:owner_id, :owner_type]
14
+ add_index :best_boy_events, :owner_id
15
+ add_index :best_boy_events, :owner_type
16
+ end
17
+ end
@@ -0,0 +1,28 @@
1
+ class CreateBestBoyReports < ActiveRecord::Migration
2
+ def change
3
+ create_table :best_boy_day_reports do |t|
4
+ t.string :owner_type
5
+ t.string :event
6
+ t.string :event_source
7
+ t.integer :month_report_id
8
+ t.integer :occurrences
9
+ t.timestamps
10
+ end
11
+
12
+ add_index :best_boy_day_reports, :created_at
13
+ add_index :best_boy_day_reports, :month_report_id
14
+ add_index :best_boy_day_reports, [:owner_type, :event, :event_source], name: "index_best_boy_day_reports_aggregated_columns"
15
+
16
+
17
+ create_table :best_boy_month_reports do |t|
18
+ t.string :owner_type
19
+ t.string :event
20
+ t.string :event_source
21
+ t.integer :occurrences, default: 0
22
+ t.timestamps
23
+ end
24
+
25
+ add_index :best_boy_month_reports, :created_at
26
+ add_index :best_boy_month_reports, [:owner_type, :event, :event_source], name: "index_best_boy_month_reports_aggregated_columns"
27
+ end
28
+ end
@@ -1,14 +1,17 @@
1
- require "best_boy/engine.rb"
1
+ require 'haml'
2
+ require "google_visualr"
3
+ require 'kaminari'
4
+ require "best_boy/engine"
5
+ require "best_boy/eventable"
6
+ require "best_boy/obeys_test_mode"
7
+ require "best_boy/reporting"
2
8
 
3
9
  module BestBoy
4
- mattr_accessor :base_controller, :before_filter, :custom_redirect, :orm,
5
- :precompile_assets, :skip_after_filter, :skip_before_filter, :test_mode
10
+ mattr_accessor :base_controller, :before_filter, :custom_redirect, :skip_after_filter, :skip_before_filter, :test_mode
6
11
 
7
12
  @@base_controller = "ApplicationController"
8
13
  @@before_filter = nil
9
14
  @@custom_redirect = nil
10
- @@orm = :active_record
11
- @@precompile_assets = false
12
15
  @@skip_after_filter = nil
13
16
  @@skip_before_filter = nil
14
17
  @@test_mode = false
@@ -1,9 +1,12 @@
1
- module BestBoyController
2
- module InstanceMethods
1
+ module BestBoy
2
+ module Controller
3
+ extend ActiveSupport::Concern
4
+
3
5
  protected
4
6
 
5
7
  def best_boy_event(obj, event, source = nil)
6
8
  obj.trigger_best_boy_event(event, source)
7
9
  end
10
+
8
11
  end
9
- end
12
+ end