express_analytics 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f7abe0673ba3998d5fd74e802648f889fa8c1902
4
- data.tar.gz: 4be92f4156160e140a2102b1eca58e1e3409ceb8
3
+ metadata.gz: 38d25e3f0fa27f02df747688b8c1e93756caba13
4
+ data.tar.gz: d2da0b5a7dc85213f75a4c3a9e18e3fecd6323b4
5
5
  SHA512:
6
- metadata.gz: 2c257ab462f9083eb471e2f8684f8e30377ea9afea07306fb394aaf4e64f191609e639619a5dedb7f4dd74e5adc0c0ac2e88c0ec787212c79cf08a0ef502fdcf
7
- data.tar.gz: 51245652186485fef2e37ba4b5f89cd99b4319b22d56ea12be25ac38b6c8b01109288041e837405378ee1b5c02370f8ead0f9f49215890a577b7455c419a5724
6
+ metadata.gz: 4d4bedce0aba485c2220dd62935d23c195e0b13612283feaa3d12ef4a6443af94664b6d7362632e0a45a886c0e491f69a15490aecdf7b275f9587ac3923f9939
7
+ data.tar.gz: 405e553371c7b215ceb06aed67ca4d1883a42ccfdf62e961c6a86ea6f28eaa05f895ad80958da1a225b1d0d9ca4d6dcd8c7b1bcfc1bac6f6a2b39e50e3092722
@@ -2,4 +2,13 @@
2
2
  *= require express_admin
3
3
  *= require_tree .
4
4
  *= require_self
5
- */
5
+ */
6
+
7
+ table.daily-statistics th {
8
+ text-align: center;
9
+ }
10
+
11
+ table.daily-statistics td {
12
+ padding-right: 3em;
13
+ text-align: right;
14
+ }
@@ -1,5 +1,7 @@
1
1
  module ExpressAnalytics
2
2
  class DailyStatisticsController < ExpressAdmin::StandardController
3
3
 
4
+ skip_logging!
5
+
4
6
  end
5
7
  end
@@ -1,5 +1,6 @@
1
1
  module ExpressAnalytics
2
2
  class DailyStatistic < ActiveRecord::Base
3
+ include ActionView::Helpers::NumberHelper
3
4
 
4
5
  def self.all_statistics
5
6
  Dir.glob(File.join(Rails.root, 'app', 'statistics', '*.rb')).map do |statistic|
@@ -28,6 +29,19 @@ module ExpressAnalytics
28
29
  self.value = send(self.class.calculate_method_name, calculated_for)
29
30
  end
30
31
 
32
+ def value_formatted
33
+ self.value
34
+ end
35
+
36
+ def self.aggregate_for(range)
37
+ aggregate_record = where(calculated_for: range).select("#{aggregation_operation.to_s.upcase}(value) AS value").order(nil).first
38
+ aggregate_record.value
39
+ end
40
+
41
+ def self.aggregation_operation
42
+ :sum
43
+ end
44
+
31
45
  private
32
46
 
33
47
  def self._arrayify(date_or_date_range)
@@ -6,19 +6,94 @@ v_box {
6
6
  }
7
7
 
8
8
  div {
9
- # table(class: table_classes) {
10
- # thead {
11
- # tr {
12
- # ExpressAnalytics::Daily.each do |column|
13
- # th(class: column.name) {
14
- # config[:sortable].present? ? sortable(column) : column.title
15
- # }
16
- # end
17
- # actions_header if should_show_actions?
18
- # hidden_columns_header_indicator if columns_hidden?
19
- # }
20
- # }
21
- # tbody {
9
+ table(class: 'table striped daily-statistics') {
10
+ thead {
11
+ tr {
12
+ th {
13
+ 'Period'
14
+ }
15
+ ExpressAnalytics::DailyStatistic.all_statistics.each do |stat_type|
16
+ th(class: stat_type.to_s.underscore) {
17
+ stat_type.to_s.titleize
18
+ }
19
+ end
20
+ }
21
+ }
22
+ tbody {
23
+ tr {
24
+ th {
25
+ 'Today'
26
+ }
27
+ ExpressAnalytics::DailyStatistic.all_statistics.each do |stat_type|
28
+ td {
29
+ stat_type.find_by_calculated_for(Date.today).value_formatted
30
+ }
31
+ end
32
+ }
33
+ tr {
34
+ th {
35
+ 'Yesterday'
36
+ }
37
+ ExpressAnalytics::DailyStatistic.all_statistics.each do |stat_type|
38
+ td {
39
+ stat_type.find_by_calculated_for(1.day.ago).value_formatted
40
+ }
41
+ end
42
+ }
43
+ tr {
44
+ th {
45
+ 'This Week'
46
+ }
47
+ ExpressAnalytics::DailyStatistic.all_statistics.each do |stat_type|
48
+ td {
49
+ stat_type.aggregate_for(Date.today.beginning_of_week..Date.today.end_of_day)
50
+ }
51
+ end
52
+ }
53
+ tr {
54
+ th {
55
+ 'Last Week'
56
+ }
57
+ ExpressAnalytics::DailyStatistic.all_statistics.each do |stat_type|
58
+ td {
59
+ stat_type.aggregate_for(1.week.ago.beginning_of_week..Date.today.beginning_of_week)
60
+ }
61
+ end
62
+ }
63
+ tr {
64
+ th {
65
+ 'This Month'
66
+ }
67
+ ExpressAnalytics::DailyStatistic.all_statistics.each do |stat_type|
68
+ td {
69
+ stat_type.aggregate_for(Date.today.beginning_of_month..Date.today.end_of_month)
70
+ }
71
+ end
72
+ }
73
+ tr {
74
+ th {
75
+ 'Last Month'
76
+ }
77
+ ExpressAnalytics::DailyStatistic.all_statistics.each do |stat_type|
78
+ td {
79
+ stat_type.aggregate_for(1.month.ago.beginning_of_month..1.month.ago.end_of_month)
80
+ }
81
+ end
82
+ }
83
+ tr {
84
+ th {
85
+ 'This Year'
86
+ }
87
+ ExpressAnalytics::DailyStatistic.all_statistics.each do |stat_type|
88
+ td {
89
+ stat_type.aggregate_for(Date.today.beginning_of_year..Date.today.end_of_day)
90
+ }
91
+ end
92
+ }
93
+
94
+ }
95
+ }
96
+
22
97
 
23
98
  }
24
99
  }
@@ -1,3 +1,3 @@
1
1
  module ExpressAnalytics
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: express_analytics
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Steven Talcott Smith