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.
@@ -10,7 +10,7 @@
10
10
  xAxis: { type: 'datetime' },
11
11
  yAxis: {
12
12
  title: { text: 'Count' },
13
- min: 0
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
- klass = klass_name.to_s.constantize
14
- steps = date_range.step(date_steps).map(&:end_of_day)
15
-
16
- steps.map do |step_end|
17
- klass.where("created_at <= ?", step_end).count
18
- end.to_s
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
@@ -1,3 +1,3 @@
1
1
  module StatBoard
2
- VERSION = '1.1.0'
2
+ VERSION = '1.1.1'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stat_board
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Eisinger