stat_board 1.0.1 → 1.0.2

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
  SHA256:
3
- metadata.gz: f97a46c0c8237e6f2646ece23864b379b67d7be751246d3d242c74c6ff82caf4
4
- data.tar.gz: 0f9503e910c1a7a99256615a4e6e429a9e04d5f752963ce41217aca6e9be51da
3
+ metadata.gz: de0bd3c95825876eee22d01d934b8289212e806ce954a817567f9c5fb3fed2d7
4
+ data.tar.gz: 452130740530b8fc1da4d3bb301618fbbf6b16ed29dabbebbe75c0c687d41419
5
5
  SHA512:
6
- metadata.gz: 716da515ff76c68cb80d3c5e952d4f2b42f5d3254cdd40c1d924179f04dd7c3828f5324d7b8937917f823f6dede0d14943498fdb3cf84da76d46374d46ab95dc
7
- data.tar.gz: 4a3c43ebf5c41ff155aedfbb11766beae24d527c0771905db4360be8a5b33f90e83a61a3c84bd52bd8ef175e68a3a87b1ad9b57953661bac2334aadadd584f17
6
+ metadata.gz: 0013c7c2908001696a1ed86c7286b7ae02dbc9a0481a7c81eb5af49cb5e795afbd52f7c272a9e1c4e8aac4fdfa2af65a074909793b3193aa4722e9ba5879a71d
7
+ data.tar.gz: 897ea2ade4d762b3b88dc56137d5a358589e08e5915e23c1bcaf966128b7e17cac79c82116392d3ed293b9512f34dd6a877a757fa8aacce178bfaa5d4868f71e
@@ -13,28 +13,12 @@ module StatBoard
13
13
  # a string of the array of the count of (klass) objects
14
14
  # along the date_range, on every displayed interval
15
15
  def resources_by_date(klass_name)
16
- klass = klass_name.to_s.constantize
17
- created_ats = klass.order(:created_at).pluck(:created_at).compact
18
- steps = date_range.step(date_steps).map(&:end_of_day)
19
- index = 0
20
- counts = created_ats.reduce(Hash.new(0)) do |counts, timestamp|
21
- cutoff = steps[index]
22
-
23
- # As long as timestamps have not exceeded the last date step
24
- if cutoff.present?
25
- if timestamp < cutoff
26
- counts[cutoff] += 1
27
- else
28
- index += 1
29
- next_cutoff = steps[index]
30
- counts[next_cutoff] += (counts[cutoff] + 1) if next_cutoff.present?
31
- end
32
- end
33
-
34
- counts
35
- end
36
-
37
- counts.values.to_s
16
+ klass = klass_name.to_s.constantize
17
+ steps = date_range.step(date_steps).map(&:end_of_day)
18
+
19
+ steps.map do |step_end|
20
+ klass.where("created_at <= ?", step_end).count
21
+ end.to_s
38
22
  end
39
23
 
40
24
  private
@@ -1,3 +1,3 @@
1
1
  module StatBoard
2
- VERSION = '1.0.1'
2
+ VERSION = '1.0.2'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stat_board
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Eisinger
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-10-29 00:00:00.000000000 Z
11
+ date: 2020-05-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -201,7 +201,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
201
201
  - !ruby/object:Gem::Version
202
202
  version: '0'
203
203
  requirements: []
204
- rubygems_version: 3.0.4
204
+ rubyforge_project:
205
+ rubygems_version: 2.7.6
205
206
  signing_key:
206
207
  specification_version: 4
207
208
  summary: Simple dashboard of records created this week, this month, and all time,