querier 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/querier.rb +11 -11
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7fcc33d6a1dadd37a5731224a5ae632d86df0a90bacad5cc0795023b337c099d
|
4
|
+
data.tar.gz: 27825d9168d18d5f08ceb206ccfe863694f38795e455b8fd4f3e286256219fcc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1e807dcf2db351b1b79a3c1c9fd2db8da1e3cab636d31b9792949fd1b3b8f6158a8f7baf65bfcd1b37373fb321866fe088b50d4c838244bf3922f7d737d17797
|
7
|
+
data.tar.gz: 1f0bdd06785eb2286c1ab243a2b040a79f5e91f397d4cd29072a2d4937ddf7c25a4653c74d9e5cdbee8a55cc0a17a9045dd9b036f7c133ce70783a20db532821
|
data/lib/querier.rb
CHANGED
@@ -28,6 +28,17 @@ class Querier
|
|
28
28
|
File.open("tmp/#{file_name}", 'w') {|f| f << self.to_sql}
|
29
29
|
end
|
30
30
|
|
31
|
+
def field_group_and_count field_name:, sort_element_index: nil, reverse_sort: true
|
32
|
+
count_result = @cached_results.group_by(&field_name).map {|k, v| [k, v.count]}
|
33
|
+
|
34
|
+
unless sort_element_index.nil?
|
35
|
+
count_result = count_result.sort_by {|el| el[sort_element_index]}
|
36
|
+
count_result.reverse! if reverse_sort.eql? true
|
37
|
+
end
|
38
|
+
|
39
|
+
count_result
|
40
|
+
end
|
41
|
+
|
31
42
|
private
|
32
43
|
|
33
44
|
def get_param_value raw_query_param
|
@@ -47,15 +58,4 @@ class Querier
|
|
47
58
|
|
48
59
|
query
|
49
60
|
end
|
50
|
-
|
51
|
-
def field_group_and_count field_name:, sort_element_index: nil, reverse_sort: true
|
52
|
-
count_result = @cached_results.group_by(&field_name).map {|k, v| [k, v.count]}
|
53
|
-
|
54
|
-
unless sort_element_index.nil?
|
55
|
-
count_result = count_result.sort_by {|el| el[sort_element_index]}
|
56
|
-
count_result.reverse! if reverse_sort.eql? true
|
57
|
-
end
|
58
|
-
|
59
|
-
count_result
|
60
|
-
end
|
61
61
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: querier
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gedean Dias
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-01-
|
11
|
+
date: 2018-01-21 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Active Record queries with variable number of params
|
14
14
|
email: gedean.dias@gmail.com
|