querier 0.2.1 → 0.3.0
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 +4 -4
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0ec1f9125483e0166d0996f231ff42f06a9ac5e7cc2da9b2e0d31ea9c62947f4
|
4
|
+
data.tar.gz: 8866efc382250a6d3e3a3a6e76cf164f31786c8c2dc42a838afe89339e8025fc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2e84803fd02bc35e4f94f7ffadaeadf89fdf6235bb0f4c4cb6c6c3b6f857dc391bc1bef6b316cd1f37e1a854c6021cc83d82670130d0a6c9fa43ea75865b8ba6
|
7
|
+
data.tar.gz: a1b0d4fa64e0d1d14c01fdf297b5868bd5e50eb4bf104f6cd63c54711f10ec7279f59c49ec2f2df7fe9a4fcf12c193b711fac0e86028db1faf29a5865f715ccd
|
data/lib/querier.rb
CHANGED
@@ -11,7 +11,7 @@ class Querier
|
|
11
11
|
|
12
12
|
attr_reader :query_execution_count, :query_template, :query_params
|
13
13
|
|
14
|
-
def initialize(
|
14
|
+
def initialize(template_query_params)
|
15
15
|
@active_record_class = self.class.active_record_class || self.class.superclass.active_record_class
|
16
16
|
@query_execution_count = 0
|
17
17
|
@query_params = template_query_params.dup
|
@@ -20,7 +20,7 @@ class Querier
|
|
20
20
|
def execute
|
21
21
|
@query_execution_count += 1
|
22
22
|
@execution_cached_result = @active_record_class.connection.select_all(fill_query_params(query_template: @query_template,
|
23
|
-
|
23
|
+
query_params: @query_params)).map(&:symbolize_keys!)
|
24
24
|
end
|
25
25
|
|
26
26
|
def cached_result(format: :hash)
|
@@ -46,7 +46,7 @@ class Querier
|
|
46
46
|
|
47
47
|
def to_file
|
48
48
|
file_name = "querier #{Time.now.strftime '[%d-%m-%Y]-[%Hh %Mm %Ss]'}.sql"
|
49
|
-
File.
|
49
|
+
File.write "tmp/#{file_name}", to_sql
|
50
50
|
end
|
51
51
|
|
52
52
|
def field_group_and_count(field_name:, sort_element_index: nil, reverse_sort: true)
|
@@ -74,7 +74,7 @@ class Querier
|
|
74
74
|
def fill_query_params(query_template:, query_params:)
|
75
75
|
query = query_template.dup
|
76
76
|
|
77
|
-
query_params.
|
77
|
+
query_params.each_pair do |query_param|
|
78
78
|
query_param_name = query_param[PARAM_NAME_INDEX].to_s
|
79
79
|
|
80
80
|
query.gsub!(/\${#{query_param_name}}/,
|
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.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gedean Dias
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-08-
|
11
|
+
date: 2021-08-30 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
|
@@ -30,14 +30,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: 3.0.2
|
34
34
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
35
35
|
requirements:
|
36
36
|
- - ">="
|
37
37
|
- !ruby/object:Gem::Version
|
38
38
|
version: '0'
|
39
39
|
requirements: []
|
40
|
-
rubygems_version: 3.2.
|
40
|
+
rubygems_version: 3.2.26
|
41
41
|
signing_key:
|
42
42
|
specification_version: 4
|
43
43
|
summary: Active Record Querier
|