querier 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/querier.rb +11 -0
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ce7e6b8f56aa2fb643082d298c3a25426d8b607abb644d73d7f007aec08ef4c1
4
- data.tar.gz: 5d384132bf782ae5de45fda80280c067023ad0cab89774887fcea4ba621fe260
3
+ metadata.gz: 31e48481f70f97cfdd3afb78f304b6aafab887c129aab817808a44271c9d2c56
4
+ data.tar.gz: e46be7a0c70ae3e3048bfaeee3c8ae4ef47d94d2fc340d530b533b938e05eaa5
5
5
  SHA512:
6
- metadata.gz: 78819735bf56a43a639c2675323b87ec9a800ff5137ec547262f904ece1fd30cf94326221ca7cc552f39d9eda611f1918917bd6e32cb2f5b1c10b819bdeac37a
7
- data.tar.gz: 4c8113e0588fde92b305171e85b625e9ec4db86ab16e1cf821ce288c87c6e1730bfdda79c24053529bb47d2e4b2b65972294c53161c1649e4a75f1db6e3414c6
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
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-07 00:00:00.000000000 Z
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