querier 0.0.5 → 0.0.6

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 -11
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 31e48481f70f97cfdd3afb78f304b6aafab887c129aab817808a44271c9d2c56
4
- data.tar.gz: e46be7a0c70ae3e3048bfaeee3c8ae4ef47d94d2fc340d530b533b938e05eaa5
3
+ metadata.gz: 7fcc33d6a1dadd37a5731224a5ae632d86df0a90bacad5cc0795023b337c099d
4
+ data.tar.gz: 27825d9168d18d5f08ceb206ccfe863694f38795e455b8fd4f3e286256219fcc
5
5
  SHA512:
6
- metadata.gz: df307669dbf4a7de150e6d3fbe197ba87dca147c21370bec05cbb9d07956f9ad6522735816d06fb8fbabe3b7f05a78bd5c2cdbe25679d2ff14989f2e6b30e1cd
7
- data.tar.gz: bbbd8830d8b90a6d2dc2a6303f043b6074dd21ed7546a96b0a209d29bf8cc3048755c58f6ed96444277af68a1cf0464b9544560b9bf746beba7649a4721b7b67
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.5
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-20 00:00:00.000000000 Z
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