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 +4 -4
- data/app/assets/stylesheets/express_analytics/admin.css +10 -1
- data/app/controllers/express_analytics/daily_statistics_controller.rb +2 -0
- data/app/models/express_analytics/daily_statistic.rb +14 -0
- data/app/views/express_analytics/daily_statistics/index.html.et +88 -13
- data/lib/express_analytics/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 38d25e3f0fa27f02df747688b8c1e93756caba13
|
4
|
+
data.tar.gz: d2da0b5a7dc85213f75a4c3a9e18e3fecd6323b4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4d4bedce0aba485c2220dd62935d23c195e0b13612283feaa3d12ef4a6443af94664b6d7362632e0a45a886c0e491f69a15490aecdf7b275f9587ac3923f9939
|
7
|
+
data.tar.gz: 405e553371c7b215ceb06aed67ca4d1883a42ccfdf62e961c6a86ea6f28eaa05f895ad80958da1a225b1d0d9ca4d6dcd8c7b1bcfc1bac6f6a2b39e50e3092722
|
@@ -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
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
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
|
}
|