hitdea_reporter 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/.rspec +2 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/Gemfile +9 -0
- data/LICENSE.txt +22 -0
- data/README.md +29 -0
- data/Rakefile +1 -0
- data/hitdea_reporter.gemspec +25 -0
- data/lib/hitdea_reporter.rb +5 -0
- data/lib/hitdea_reporter/force_field.rb +40 -0
- data/lib/hitdea_reporter/hits.rb +44 -0
- data/lib/hitdea_reporter/pca.rb +42 -0
- data/lib/hitdea_reporter/tool.rb +93 -0
- data/lib/hitdea_reporter/version.rb +3 -0
- data/spec/hitdea_reporter/force_field_spec.rb +43 -0
- data/spec/hitdea_reporter/hits_spec.rb +45 -0
- data/spec/hitdea_reporter/pca_spec.rb +65 -0
- data/spec/hitdea_reporter/tool_spec.rb +180 -0
- data/spec/spec_helper.rb +6 -0
- metadata +125 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 10184e65fd46d35578381a23e386df358b8b06f7
|
4
|
+
data.tar.gz: 8ec6709f02dcb08d375982bacb376ee5fa6ea69b
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 863e234f92012beb07187273309ff292b16c5169e58235558a8f265c3e4dbdcd9a3ada4bc0ac403c2ba20e8741526b0b423963cc39dc2f2065180ea7f812ca51
|
7
|
+
data.tar.gz: a0afb540250acea96ffa2c967acb6097bbd6299fb7c120c401132ec922f93e8111f1652e7d8af1c998135113d8af5140b930389458e2b7d153fd170c5af55f36
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.ruby-gemset
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
hitdea_reporter
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.2.1
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Agnieszka Matysek
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# HitdeaReporter
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'hitdea_reporter'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install hitdea_reporter
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
TODO: Write usage instructions here
|
22
|
+
|
23
|
+
## Contributing
|
24
|
+
|
25
|
+
1. Fork it
|
26
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'bundler/gem_tasks'
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'hitdea_reporter/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'hitdea_reporter'
|
8
|
+
spec.version = HitdeaReporter::VERSION
|
9
|
+
spec.authors = ['Agnieszka Matysek']
|
10
|
+
spec.email = ['amatysek@fractalsoft.org']
|
11
|
+
spec.summary = %q{hitdea reporter}
|
12
|
+
spec.homepage = ''
|
13
|
+
spec.license = 'MIT'
|
14
|
+
|
15
|
+
spec.files = `git ls-files`.split($/)
|
16
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
17
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
|
+
spec.require_paths = ['lib']
|
19
|
+
|
20
|
+
spec.add_dependency 'statistical_methods', '~> 1.0'
|
21
|
+
|
22
|
+
spec.add_development_dependency 'bundler', '~> 1.3'
|
23
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
24
|
+
spec.add_development_dependency 'activesupport', '~> 4.2'
|
25
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module HitdeaReporter
|
2
|
+
# ForceField reporter
|
3
|
+
class ForceField
|
4
|
+
def initialize(data, idea_names, category_names)
|
5
|
+
@data = data
|
6
|
+
@idea_names = Hash[idea_names]
|
7
|
+
@category_names = Hash[category_names]
|
8
|
+
end
|
9
|
+
|
10
|
+
def prepare
|
11
|
+
new_header = header
|
12
|
+
new_header[2] = :idea_id
|
13
|
+
{ header: new_header, data: data }
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def header
|
19
|
+
[:idea, :category, :idea, :mean, :standard_deviation, :min, :max]
|
20
|
+
end
|
21
|
+
|
22
|
+
def data
|
23
|
+
prepare_data.map do |row|
|
24
|
+
idea = @idea_names[row[0]]
|
25
|
+
category = @category_names[row[1]]
|
26
|
+
[idea, category, row[2..6]].flatten
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def prepare_data
|
31
|
+
Tool.new(
|
32
|
+
@data,
|
33
|
+
header: [:idea, :category, :vote, :user],
|
34
|
+
methods: [:mean, :standard_deviation, :min, :max],
|
35
|
+
grouped: [:idea, :category],
|
36
|
+
results: header
|
37
|
+
).show
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'active_support/core_ext/hash'
|
2
|
+
|
3
|
+
module HitdeaReporter
|
4
|
+
# Hits Reporter
|
5
|
+
class Hits
|
6
|
+
def initialize(data, names)
|
7
|
+
@data = data
|
8
|
+
@names = Hash[names]
|
9
|
+
end
|
10
|
+
|
11
|
+
def prepare
|
12
|
+
new_header = header
|
13
|
+
new_header[1] = :idea_id
|
14
|
+
{ header: new_header, data: data_with_empty_rows }
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def header
|
20
|
+
[:idea, :idea, :sum, :user]
|
21
|
+
end
|
22
|
+
|
23
|
+
def data
|
24
|
+
prepare_data.map do |row|
|
25
|
+
[@names[row.first], row[1..3]].flatten
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def prepare_data
|
30
|
+
Tool.new(
|
31
|
+
@data,
|
32
|
+
header: [:idea, :vote, :user],
|
33
|
+
methods: [:sum],
|
34
|
+
grouped: [:idea],
|
35
|
+
results: header
|
36
|
+
).show
|
37
|
+
end
|
38
|
+
|
39
|
+
def data_with_empty_rows
|
40
|
+
array = @names.except(*@data.transpose[0])
|
41
|
+
data + array.map { |id, name| [name, id, 0, 0] }
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
module HitdeaReporter
|
2
|
+
# Pca Reporter
|
3
|
+
class Pca
|
4
|
+
def initialize(data, names)
|
5
|
+
@data = sum_by_user(data)
|
6
|
+
@names = Hash[names]
|
7
|
+
end
|
8
|
+
|
9
|
+
def prepare
|
10
|
+
new_header = header
|
11
|
+
new_header[1] = :idea_id
|
12
|
+
{ header: new_header, data: data }
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def header
|
18
|
+
[:idea, :idea, :sum, :mean, :standard_deviation, :min, :max]
|
19
|
+
end
|
20
|
+
|
21
|
+
def data
|
22
|
+
prepare_data.map do |row|
|
23
|
+
[@names[row.first], row[1..6]].flatten
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def sum_by_user(data)
|
28
|
+
grouped_data = data.group_by { |column| column[0..1] }
|
29
|
+
grouped_data.map { |key, value| [*key, value.transpose[2].inject(:+)] }
|
30
|
+
end
|
31
|
+
|
32
|
+
def prepare_data
|
33
|
+
Tool.new(
|
34
|
+
@data,
|
35
|
+
header: [:idea, :user, :vote],
|
36
|
+
methods: [:sum, :mean, :standard_deviation, :min, :max],
|
37
|
+
grouped: [:idea],
|
38
|
+
results: header
|
39
|
+
).show
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,93 @@
|
|
1
|
+
require 'statistical_methods'
|
2
|
+
|
3
|
+
module HitdeaReporter
|
4
|
+
class Tool
|
5
|
+
class ::Array
|
6
|
+
def count_column(index)
|
7
|
+
transpose[index].uniq.count
|
8
|
+
end
|
9
|
+
|
10
|
+
def remove_nil
|
11
|
+
delete_if { |row| row.include?(nil) }
|
12
|
+
end
|
13
|
+
|
14
|
+
def indexes(array)
|
15
|
+
map { |item| array.index(item) }
|
16
|
+
end
|
17
|
+
|
18
|
+
def group_index(array)
|
19
|
+
group_by { |column| array.values(column) }
|
20
|
+
end
|
21
|
+
|
22
|
+
def values(columns)
|
23
|
+
map { |index| columns[index] }
|
24
|
+
end
|
25
|
+
|
26
|
+
def hashed(array)
|
27
|
+
Hash[map { |item| [item, array[index(item)]] }]
|
28
|
+
end
|
29
|
+
|
30
|
+
def run(object, params)
|
31
|
+
Hash[map { |method| [method, object.send(method, params)] }]
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
attr_reader :data
|
36
|
+
|
37
|
+
def initialize(data, params)
|
38
|
+
@params = params
|
39
|
+
@data = data.remove_nil
|
40
|
+
@stat = ::StatisticalMethods::Computer.new
|
41
|
+
end
|
42
|
+
|
43
|
+
def show
|
44
|
+
result = []
|
45
|
+
grouped_data.each do |key, array|
|
46
|
+
result << count_row(key, array)
|
47
|
+
end
|
48
|
+
result
|
49
|
+
end
|
50
|
+
|
51
|
+
private
|
52
|
+
|
53
|
+
def grouped
|
54
|
+
@params[:grouped] || []
|
55
|
+
end
|
56
|
+
|
57
|
+
def header
|
58
|
+
@params[:header] || []
|
59
|
+
end
|
60
|
+
|
61
|
+
def methods
|
62
|
+
@params[:methods] || []
|
63
|
+
end
|
64
|
+
|
65
|
+
def results
|
66
|
+
@params[:results] || []
|
67
|
+
end
|
68
|
+
|
69
|
+
def count_row(key, array)
|
70
|
+
values = array.transpose[vote_index]
|
71
|
+
tmp = { user: array.count_column(user_index) }
|
72
|
+
tmp.merge!(grouped.hashed(key))
|
73
|
+
tmp.merge!(methods.run(@stat, values))
|
74
|
+
results.values(tmp)
|
75
|
+
end
|
76
|
+
|
77
|
+
def grouped_indexes
|
78
|
+
grouped.indexes(header)
|
79
|
+
end
|
80
|
+
|
81
|
+
def user_index
|
82
|
+
@user_index ||= header.index(:user)
|
83
|
+
end
|
84
|
+
|
85
|
+
def vote_index
|
86
|
+
@vote_index ||= header.index(:vote)
|
87
|
+
end
|
88
|
+
|
89
|
+
def grouped_data
|
90
|
+
@data.group_index(grouped_indexes)
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module HitdeaReporter
|
4
|
+
describe ForceField do
|
5
|
+
subject { ForceField.new(data, idea_names, category_names) }
|
6
|
+
let(:header) do
|
7
|
+
[:idea, :category, :idea_id, :mean, :standard_deviation, :min, :max]
|
8
|
+
end
|
9
|
+
let(:idea_names) { [[1, 'foobar']] }
|
10
|
+
let(:category_names) { [[3, 'barfoo']] }
|
11
|
+
let(:data) do
|
12
|
+
[
|
13
|
+
[1, 3, 2, 1],
|
14
|
+
[1, 3, 1, 2]
|
15
|
+
]
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'show array of report results' do
|
19
|
+
report = subject.prepare
|
20
|
+
|
21
|
+
expect(report).to be_an_instance_of Hash
|
22
|
+
expect(report[:data]).to be_an_instance_of Array
|
23
|
+
expect(report[:data].first[0]).to be_an_instance_of String
|
24
|
+
expect(report[:data].first[1]).to be_an_instance_of String
|
25
|
+
expect(report[:data].first[2]).to be_an_instance_of Fixnum
|
26
|
+
expect(report[:data].first[3]).to be_an_instance_of Float
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'use report class' do
|
30
|
+
expect_any_instance_of(Tool).to receive(:show).and_return([[1]])
|
31
|
+
subject.prepare
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'include header' do
|
35
|
+
expect(subject.prepare[:header]).to eq header
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'header and data have the same size' do
|
39
|
+
report = subject.prepare
|
40
|
+
expect(report[:data].first.size).to eq report[:header].size
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module HitdeaReporter
|
4
|
+
describe Hits do
|
5
|
+
subject { Hits.new(data, idea_names) }
|
6
|
+
let(:header) { [:idea, :idea_id, :sum, :user] }
|
7
|
+
let(:idea_names) { [[1, 'foobar']] }
|
8
|
+
let(:data) do
|
9
|
+
[
|
10
|
+
[1, 2, 1],
|
11
|
+
[1, 1, 2]
|
12
|
+
]
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'show array of report results' do
|
16
|
+
report = subject.prepare
|
17
|
+
|
18
|
+
expect(report).to be_an_instance_of Hash
|
19
|
+
expect(report[:data]).to be_an_instance_of Array
|
20
|
+
expect(report[:data].first.first).to be_an_instance_of String
|
21
|
+
expect(report[:data].first.last).to be_an_instance_of Fixnum
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'use report class' do
|
25
|
+
expect_any_instance_of(Tool).to receive(:show).and_return([[1]])
|
26
|
+
subject.prepare
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'include header' do
|
30
|
+
expect(subject.prepare[:header]).to eq header
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'header and data have the same size' do
|
34
|
+
report = subject.prepare
|
35
|
+
expect(report[:data].first.size).to eq report[:header].size
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'show ideas without votes' do
|
39
|
+
idea_names = [[1, 'foobar'], [2, 'barfoo']]
|
40
|
+
report = Hits.new(data, idea_names).prepare
|
41
|
+
|
42
|
+
expect(report[:data]).to include(['barfoo', 2, 0, 0])
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module HitdeaReporter
|
4
|
+
describe Pca do
|
5
|
+
subject { Pca.new(data, idea_names) }
|
6
|
+
let(:header) do
|
7
|
+
[:idea, :idea_id, :sum, :mean, :standard_deviation, :min, :max]
|
8
|
+
end
|
9
|
+
let(:idea_names) { [[1, 'foobar']] }
|
10
|
+
let(:data) do
|
11
|
+
[
|
12
|
+
[1, 2, 1],
|
13
|
+
[1, 1, 2]
|
14
|
+
]
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'show array of report results' do
|
18
|
+
report = subject.prepare
|
19
|
+
|
20
|
+
expect(report).to be_an_instance_of Hash
|
21
|
+
expect(report[:data]).to be_an_instance_of Array
|
22
|
+
expect(report[:data].first.first).to be_an_instance_of String
|
23
|
+
expect(report[:data].first[2]).to be_an_instance_of Fixnum
|
24
|
+
expect(report[:data].first[4]).to be_an_instance_of Float
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'use report class' do
|
28
|
+
expect_any_instance_of(Tool).to receive(:show).and_return([[1]])
|
29
|
+
subject.prepare
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'include header' do
|
33
|
+
expect(subject.prepare[:header]).to eq header
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'header and data have the same size' do
|
37
|
+
report = subject.prepare
|
38
|
+
expect(report[:data].first.size).to eq report[:header].size
|
39
|
+
end
|
40
|
+
|
41
|
+
context 'group and sum by many parameters' do
|
42
|
+
let(:idea_names) { [[1, 'foobar'], [2, 'barfoo']] }
|
43
|
+
let(:data) do
|
44
|
+
[
|
45
|
+
[1, 1, 3],
|
46
|
+
[1, 1, 1],
|
47
|
+
[1, 2, 1],
|
48
|
+
[1, 2, 1],
|
49
|
+
[2, 1, 2]
|
50
|
+
]
|
51
|
+
end
|
52
|
+
let(:result) do
|
53
|
+
[
|
54
|
+
['foobar', 1, 6, 3.0, 1.0, 2, 4],
|
55
|
+
['barfoo', 2, 2, 2.0, 0.0, 2, 2]
|
56
|
+
]
|
57
|
+
end
|
58
|
+
|
59
|
+
it do
|
60
|
+
report = subject.prepare
|
61
|
+
expect(report[:data]).to eq result
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
@@ -0,0 +1,180 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module HitdeaReporter
|
4
|
+
describe Tool do
|
5
|
+
let(:params) do
|
6
|
+
{
|
7
|
+
header: [:idea, :vote, :user],
|
8
|
+
methods: [:sum],
|
9
|
+
grouped: [:idea],
|
10
|
+
results: [:idea, :sum, :user]
|
11
|
+
}
|
12
|
+
end
|
13
|
+
subject { Tool.new(data, params) }
|
14
|
+
|
15
|
+
let(:data) do
|
16
|
+
[
|
17
|
+
[1, 2, 1],
|
18
|
+
[1, 1, 2],
|
19
|
+
[2, 3, 1],
|
20
|
+
[3, 2, 1],
|
21
|
+
[3, 1, 2]
|
22
|
+
]
|
23
|
+
end
|
24
|
+
let(:result) do
|
25
|
+
[
|
26
|
+
[1, 3, 2],
|
27
|
+
[2, 3, 1],
|
28
|
+
[3, 3, 2]
|
29
|
+
]
|
30
|
+
end
|
31
|
+
|
32
|
+
it { expect(subject.data).to eq data }
|
33
|
+
it { expect(subject.show).to eq result }
|
34
|
+
|
35
|
+
context 'sum all votes and count users' do
|
36
|
+
let(:data) do
|
37
|
+
[
|
38
|
+
[1, 2, 1],
|
39
|
+
[1, 1, 2]
|
40
|
+
]
|
41
|
+
end
|
42
|
+
let(:result) { [[1, 3, 2]] }
|
43
|
+
|
44
|
+
it { expect(subject.show).to eq result }
|
45
|
+
end
|
46
|
+
|
47
|
+
context 'group by idea, sum and count' do
|
48
|
+
let(:data) do
|
49
|
+
[
|
50
|
+
[1, 2, 1],
|
51
|
+
[1, 1, 2],
|
52
|
+
[2, 3, 1]
|
53
|
+
]
|
54
|
+
end
|
55
|
+
let(:result) do
|
56
|
+
[
|
57
|
+
[1, 3, 2],
|
58
|
+
[2, 3, 1]
|
59
|
+
]
|
60
|
+
end
|
61
|
+
|
62
|
+
it { expect(subject.show).to eq result }
|
63
|
+
end
|
64
|
+
|
65
|
+
context 'count only not nil elements' do
|
66
|
+
let(:data) do
|
67
|
+
[
|
68
|
+
[nil, 2, 1],
|
69
|
+
[1, nil, 2],
|
70
|
+
[2, 3, nil],
|
71
|
+
[1, 2, 5]
|
72
|
+
]
|
73
|
+
end
|
74
|
+
let(:result) { [[1, 2, 1]] }
|
75
|
+
|
76
|
+
it { expect(subject.show).to eq result }
|
77
|
+
end
|
78
|
+
|
79
|
+
context 'group, sum and cound on different position' do
|
80
|
+
let(:params) do
|
81
|
+
{
|
82
|
+
header: [:user, :idea, :vote],
|
83
|
+
methods: [:sum],
|
84
|
+
grouped: [:idea],
|
85
|
+
results: [:user, :idea, :sum]
|
86
|
+
}
|
87
|
+
end
|
88
|
+
let(:data) do
|
89
|
+
[
|
90
|
+
[1, 1, 2],
|
91
|
+
[2, 1, 1]
|
92
|
+
]
|
93
|
+
end
|
94
|
+
let(:result) { [[2, 1, 3]] }
|
95
|
+
|
96
|
+
it { expect(subject.show).to eq result }
|
97
|
+
end
|
98
|
+
|
99
|
+
context 'count also mean' do
|
100
|
+
let(:params) do
|
101
|
+
{
|
102
|
+
header: [:user, :idea, :vote],
|
103
|
+
methods: [:sum, :mean],
|
104
|
+
grouped: [:idea],
|
105
|
+
results: [:user, :idea, :sum, :mean]
|
106
|
+
}
|
107
|
+
end
|
108
|
+
let(:data) do
|
109
|
+
[
|
110
|
+
[1, 1, 2],
|
111
|
+
[2, 1, 1],
|
112
|
+
[3, 1, 3]
|
113
|
+
]
|
114
|
+
end
|
115
|
+
let(:result) { [[3, 1, 6, 2.0]] }
|
116
|
+
|
117
|
+
it { expect(subject.show).to eq result }
|
118
|
+
end
|
119
|
+
|
120
|
+
context 'group by many parameters' do
|
121
|
+
let(:params) do
|
122
|
+
{
|
123
|
+
header: [:idea, :category, :vote, :user],
|
124
|
+
methods: [:sum],
|
125
|
+
grouped: [:idea, :category],
|
126
|
+
results: [:idea, :category, :sum, :user]
|
127
|
+
}
|
128
|
+
end
|
129
|
+
let(:data) do
|
130
|
+
[
|
131
|
+
[1, 1, 2, 1],
|
132
|
+
[1, 2, 1, 2],
|
133
|
+
[1, 1, 1, 2],
|
134
|
+
[2, 1, 1, 2],
|
135
|
+
[2, 1, 1, 1],
|
136
|
+
[2, 2, 1, 1]
|
137
|
+
]
|
138
|
+
end
|
139
|
+
let(:result) do
|
140
|
+
[
|
141
|
+
[1, 1, 3, 2],
|
142
|
+
[1, 2, 1, 1],
|
143
|
+
[2, 1, 2, 2],
|
144
|
+
[2, 2, 1, 1]
|
145
|
+
]
|
146
|
+
end
|
147
|
+
|
148
|
+
it { expect(subject.show).to eq result }
|
149
|
+
end
|
150
|
+
|
151
|
+
context 'count only uniq users' do
|
152
|
+
let(:params) do
|
153
|
+
{
|
154
|
+
header: [:idea, :vote, :user],
|
155
|
+
methods: [:sum],
|
156
|
+
grouped: [:idea],
|
157
|
+
results: [:idea, :sum, :user]
|
158
|
+
}
|
159
|
+
end
|
160
|
+
let(:data) do
|
161
|
+
[
|
162
|
+
[1, 2, 1],
|
163
|
+
[1, 1, 2],
|
164
|
+
[1, 1, 2],
|
165
|
+
[2, 1, 2],
|
166
|
+
[2, 1, 1],
|
167
|
+
[2, 1, 1]
|
168
|
+
]
|
169
|
+
end
|
170
|
+
let(:result) do
|
171
|
+
[
|
172
|
+
[1, 4, 2],
|
173
|
+
[2, 3, 2]
|
174
|
+
]
|
175
|
+
end
|
176
|
+
|
177
|
+
it { expect(subject.show).to eq result }
|
178
|
+
end
|
179
|
+
end
|
180
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,125 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: hitdea_reporter
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Agnieszka Matysek
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-06-30 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: statistical_methods
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.3'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.3'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: activesupport
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '4.2'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '4.2'
|
69
|
+
description:
|
70
|
+
email:
|
71
|
+
- amatysek@fractalsoft.org
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- ".gitignore"
|
77
|
+
- ".rspec"
|
78
|
+
- ".ruby-gemset"
|
79
|
+
- ".ruby-version"
|
80
|
+
- Gemfile
|
81
|
+
- LICENSE.txt
|
82
|
+
- README.md
|
83
|
+
- Rakefile
|
84
|
+
- hitdea_reporter.gemspec
|
85
|
+
- lib/hitdea_reporter.rb
|
86
|
+
- lib/hitdea_reporter/force_field.rb
|
87
|
+
- lib/hitdea_reporter/hits.rb
|
88
|
+
- lib/hitdea_reporter/pca.rb
|
89
|
+
- lib/hitdea_reporter/tool.rb
|
90
|
+
- lib/hitdea_reporter/version.rb
|
91
|
+
- spec/hitdea_reporter/force_field_spec.rb
|
92
|
+
- spec/hitdea_reporter/hits_spec.rb
|
93
|
+
- spec/hitdea_reporter/pca_spec.rb
|
94
|
+
- spec/hitdea_reporter/tool_spec.rb
|
95
|
+
- spec/spec_helper.rb
|
96
|
+
homepage: ''
|
97
|
+
licenses:
|
98
|
+
- MIT
|
99
|
+
metadata: {}
|
100
|
+
post_install_message:
|
101
|
+
rdoc_options: []
|
102
|
+
require_paths:
|
103
|
+
- lib
|
104
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
105
|
+
requirements:
|
106
|
+
- - ">="
|
107
|
+
- !ruby/object:Gem::Version
|
108
|
+
version: '0'
|
109
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
110
|
+
requirements:
|
111
|
+
- - ">="
|
112
|
+
- !ruby/object:Gem::Version
|
113
|
+
version: '0'
|
114
|
+
requirements: []
|
115
|
+
rubyforge_project:
|
116
|
+
rubygems_version: 2.4.7
|
117
|
+
signing_key:
|
118
|
+
specification_version: 4
|
119
|
+
summary: hitdea reporter
|
120
|
+
test_files:
|
121
|
+
- spec/hitdea_reporter/force_field_spec.rb
|
122
|
+
- spec/hitdea_reporter/hits_spec.rb
|
123
|
+
- spec/hitdea_reporter/pca_spec.rb
|
124
|
+
- spec/hitdea_reporter/tool_spec.rb
|
125
|
+
- spec/spec_helper.rb
|