stat_board 0.1.7 → 0.1.8
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +3 -1
- data/app/controllers/stat_board/application_controller.rb +5 -28
- data/lib/stat_board/graph_helper.rb +43 -0
- data/lib/stat_board/version.rb +1 -1
- data/lib/stat_board.rb +1 -0
- metadata +44 -11
data/Rakefile
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
#!/usr/bin/env rake
|
2
|
+
puts ENV['BUNDLE_GEMFILE'].inspect
|
2
3
|
begin
|
3
4
|
require 'bundler/setup'
|
5
|
+
require 'appraisal'
|
4
6
|
rescue LoadError
|
5
7
|
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
6
8
|
end
|
@@ -27,6 +29,6 @@ Bundler::GemHelper.install_tasks
|
|
27
29
|
|
28
30
|
require 'rspec/core/rake_task'
|
29
31
|
|
30
|
-
RSpec::Core::RakeTask.new(:spec)
|
32
|
+
RSpec::Core::RakeTask.new(:spec => 'app:db:test:prepare')
|
31
33
|
|
32
34
|
task :default => :spec
|
@@ -3,36 +3,13 @@ module StatBoard
|
|
3
3
|
|
4
4
|
private
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
@date_steps ||= date_range.count / [date_range.count, 50].min
|
10
|
-
end
|
11
|
-
|
12
|
-
def first_day_ever
|
13
|
-
@first_day_ever ||= first_day_of_each_model.sort.first
|
14
|
-
end
|
15
|
-
|
16
|
-
def resources_by_date(klass_name)
|
17
|
-
klass = klass_name.to_s.constantize
|
18
|
-
created_ats = klass.pluck(:created_at).map(&:to_date)
|
19
|
-
|
20
|
-
date_range.step(date_steps).map do |date|
|
21
|
-
created_ats.count{|c_a| c_a < date}
|
22
|
-
end.to_s
|
23
|
-
end
|
24
|
-
|
25
|
-
def first_day_of_each_model
|
26
|
-
StatBoard.models.map { |m| first_day_of(m) }
|
27
|
-
end
|
28
|
-
|
29
|
-
def first_day_of(klass_name)
|
30
|
-
klass = klass_name.to_s.constantize
|
31
|
-
klass.order("created_at ASC").first.try(:created_at) || Time.now
|
6
|
+
[:date_steps, :first_day_ever, :resources_by_date].each do |method|
|
7
|
+
helper_method method
|
8
|
+
delegate method, :to => :graph_helper
|
32
9
|
end
|
33
10
|
|
34
|
-
def
|
35
|
-
@
|
11
|
+
def graph_helper
|
12
|
+
@graph_helper ||= GraphHelper.new
|
36
13
|
end
|
37
14
|
|
38
15
|
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module StatBoard
|
2
|
+
class GraphHelper
|
3
|
+
|
4
|
+
# number of days per interval on the graph's x axis
|
5
|
+
def date_steps
|
6
|
+
@date_steps ||= date_range.count / [date_range.count, 50].min
|
7
|
+
end
|
8
|
+
|
9
|
+
def first_day_ever
|
10
|
+
@first_day_ever ||= first_day_of_each_model.sort.first
|
11
|
+
end
|
12
|
+
|
13
|
+
# a string of the array of the count of (klass) objects
|
14
|
+
# along the date_range, on every displayed interval
|
15
|
+
def resources_by_date(klass_name)
|
16
|
+
klass = klass_name.to_s.constantize
|
17
|
+
created_ats = klass.pluck(:created_at).compact.map(&:to_date)
|
18
|
+
|
19
|
+
date_range.step(date_steps).map do |date|
|
20
|
+
created_ats.count{|c_a| c_a < date}
|
21
|
+
end.to_s
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
# range of dates shown on the graph (array of days)
|
27
|
+
def date_range
|
28
|
+
@date_range ||= first_day_ever.to_date..Date.today
|
29
|
+
end
|
30
|
+
|
31
|
+
def first_day_of_each_model
|
32
|
+
StatBoard.models.map { |m| first_day_of(m) }
|
33
|
+
end
|
34
|
+
|
35
|
+
# returns the earliest `created_at` of a given class
|
36
|
+
# returns `Time.now` if none is available
|
37
|
+
def first_day_of(klass_name)
|
38
|
+
klass = klass_name.to_s.constantize
|
39
|
+
klass.order("created_at ASC").first.try(:created_at) || Time.now
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
end
|
data/lib/stat_board/version.rb
CHANGED
data/lib/stat_board.rb
CHANGED
@@ -3,6 +3,7 @@ require "stat_board/reports/report"
|
|
3
3
|
require "stat_board/reports/overall_report"
|
4
4
|
require "stat_board/reports/monthly_report"
|
5
5
|
require "stat_board/reports/weekly_report"
|
6
|
+
require "stat_board/graph_helper"
|
6
7
|
|
7
8
|
module StatBoard
|
8
9
|
mattr_accessor :models, :title, :display_graph, :username, :password
|
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: 0.1.
|
4
|
+
version: 0.1.8
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,24 +9,24 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2014-05-20 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
|
-
- -
|
19
|
+
- - ! '>='
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version:
|
21
|
+
version: 3.2.0
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
25
|
none: false
|
26
26
|
requirements:
|
27
|
-
- -
|
27
|
+
- - ! '>='
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version:
|
29
|
+
version: 3.2.0
|
30
30
|
- !ruby/object:Gem::Dependency
|
31
31
|
name: sqlite3
|
32
32
|
requirement: !ruby/object:Gem::Requirement
|
@@ -128,17 +128,49 @@ dependencies:
|
|
128
128
|
requirement: !ruby/object:Gem::Requirement
|
129
129
|
none: false
|
130
130
|
requirements:
|
131
|
-
- -
|
131
|
+
- - ! '>='
|
132
132
|
- !ruby/object:Gem::Version
|
133
|
-
version: 0
|
133
|
+
version: '0'
|
134
134
|
type: :development
|
135
135
|
prerelease: false
|
136
136
|
version_requirements: !ruby/object:Gem::Requirement
|
137
137
|
none: false
|
138
138
|
requirements:
|
139
|
-
- -
|
139
|
+
- - ! '>='
|
140
|
+
- !ruby/object:Gem::Version
|
141
|
+
version: '0'
|
142
|
+
- !ruby/object:Gem::Dependency
|
143
|
+
name: appraisal
|
144
|
+
requirement: !ruby/object:Gem::Requirement
|
145
|
+
none: false
|
146
|
+
requirements:
|
147
|
+
- - ! '>='
|
148
|
+
- !ruby/object:Gem::Version
|
149
|
+
version: '0'
|
150
|
+
type: :development
|
151
|
+
prerelease: false
|
152
|
+
version_requirements: !ruby/object:Gem::Requirement
|
153
|
+
none: false
|
154
|
+
requirements:
|
155
|
+
- - ! '>='
|
156
|
+
- !ruby/object:Gem::Version
|
157
|
+
version: '0'
|
158
|
+
- !ruby/object:Gem::Dependency
|
159
|
+
name: rake
|
160
|
+
requirement: !ruby/object:Gem::Requirement
|
161
|
+
none: false
|
162
|
+
requirements:
|
163
|
+
- - ! '>='
|
164
|
+
- !ruby/object:Gem::Version
|
165
|
+
version: '0'
|
166
|
+
type: :development
|
167
|
+
prerelease: false
|
168
|
+
version_requirements: !ruby/object:Gem::Requirement
|
169
|
+
none: false
|
170
|
+
requirements:
|
171
|
+
- - ! '>='
|
140
172
|
- !ruby/object:Gem::Version
|
141
|
-
version: 0
|
173
|
+
version: '0'
|
142
174
|
description: Simple dashboard of records created this week, this month, and all time,
|
143
175
|
mountable as a Rails Engine.
|
144
176
|
email:
|
@@ -157,6 +189,7 @@ files:
|
|
157
189
|
- app/views/stat_board/stats/index.html.erb
|
158
190
|
- config/routes.rb
|
159
191
|
- lib/stat_board/engine.rb
|
192
|
+
- lib/stat_board/graph_helper.rb
|
160
193
|
- lib/stat_board/reports/monthly_report.rb
|
161
194
|
- lib/stat_board/reports/overall_report.rb
|
162
195
|
- lib/stat_board/reports/report.rb
|
@@ -188,7 +221,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
188
221
|
version: '0'
|
189
222
|
requirements: []
|
190
223
|
rubyforge_project:
|
191
|
-
rubygems_version: 1.8.
|
224
|
+
rubygems_version: 1.8.23.2
|
192
225
|
signing_key:
|
193
226
|
specification_version: 3
|
194
227
|
summary: Simple dashboard of records created this week, this month, and all time,
|