querier 0.0.4 → 0.0.5
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 -0
- 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: 31e48481f70f97cfdd3afb78f304b6aafab887c129aab817808a44271c9d2c56
|
4
|
+
data.tar.gz: e46be7a0c70ae3e3048bfaeee3c8ae4ef47d94d2fc340d530b533b938e05eaa5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: df307669dbf4a7de150e6d3fbe197ba87dca147c21370bec05cbb9d07956f9ad6522735816d06fb8fbabe3b7f05a78bd5c2cdbe25679d2ff14989f2e6b30e1cd
|
7
|
+
data.tar.gz: bbbd8830d8b90a6d2dc2a6303f043b6074dd21ed7546a96b0a209d29bf8cc3048755c58f6ed96444277af68a1cf0464b9544560b9bf746beba7649a4721b7b67
|
data/lib/querier.rb
CHANGED
@@ -47,4 +47,15 @@ class Querier
|
|
47
47
|
|
48
48
|
query
|
49
49
|
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
|
50
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.5
|
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-20 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
|