stat_board 1.1.0 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/assets/javascripts/stat_board/highcharts.js +522 -39700
- data/app/views/stat_board/stats/_graph.html.erb +2 -2
- data/lib/stat_board/graph_helper.rb +9 -6
- data/lib/stat_board/version.rb +1 -1
- metadata +1 -1
@@ -10,7 +10,7 @@
|
|
10
10
|
xAxis: { type: 'datetime' },
|
11
11
|
yAxis: {
|
12
12
|
title: { text: 'Count' },
|
13
|
-
min:
|
13
|
+
min: <%= StatBoard.models.map { |model| resources_by_date(model.to_s) }.map(&:first).min %>
|
14
14
|
},
|
15
15
|
series: [
|
16
16
|
<% StatBoard.models.each do |model| %>
|
@@ -18,7 +18,7 @@
|
|
18
18
|
name: "<%= model.to_s.pluralize %>",
|
19
19
|
pointInterval: pointInterval,
|
20
20
|
pointStart: pointStart,
|
21
|
-
data: <%= resources_by_date(model.to_s) %>
|
21
|
+
data: <%= resources_by_date(model.to_s).to_s %>
|
22
22
|
},
|
23
23
|
<% end %>
|
24
24
|
]
|
@@ -10,12 +10,15 @@ module StatBoard
|
|
10
10
|
# a string of the array of the count of (klass) objects
|
11
11
|
# along the date_range, on every displayed interval
|
12
12
|
def resources_by_date(klass_name)
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
13
|
+
@resrouces_cache ||= {}
|
14
|
+
@resrouces_cache[klass_name] ||= begin
|
15
|
+
klass = klass_name.to_s.constantize
|
16
|
+
steps = date_range.step(date_steps).map(&:end_of_day)
|
17
|
+
|
18
|
+
steps.map do |step_end|
|
19
|
+
klass.where("created_at <= ?", step_end).count
|
20
|
+
end
|
21
|
+
end
|
19
22
|
end
|
20
23
|
|
21
24
|
# number of days per interval on the graph's x axis
|
data/lib/stat_board/version.rb
CHANGED