mincer 0.2.15 → 0.2.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/README.md +5 -1
- data/lib/mincer.rb +1 -2
- data/lib/mincer/processors/pg_json_dumper/processor.rb +4 -1
- data/lib/mincer/processors/pg_search/processor.rb +1 -1
- data/lib/mincer/processors/pg_search/search_engines/fulltext.rb +5 -2
- data/lib/mincer/version.rb +1 -1
- data/mincer.gemspec +1 -1
- data/spec/lib/mincer/processors/pg_json_dumper/processor_spec.rb +3 -3
- metadata +3 -5
- data/lib/mincer/core_ext/string.rb +0 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 57615c10653f4eee6875661054d63fbb089e19578d9b23f518eb181f1325c2ae
|
4
|
+
data.tar.gz: '09833041518630ceaf52321fbfe20624ac9b2bc205404215d528abfab9a32ce0'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8f05956a84834da93f1119cb71e593da3997dcf93099983d64b2d98b0b0b758947573987eccb7a34544eddd1513fb4f2531336c737d605d8300c659b14e39d61
|
7
|
+
data.tar.gz: 962e4462917b40105df7243d30bf8459cfa44951644de57ee550e80e1b50c064e7a61915bf5fa4fd653cf2c622d58a63f694f7d1340abe8b27d84d3c3747873e
|
data/README.md
CHANGED
@@ -218,7 +218,11 @@ If you set `ignore_case` attribute to true - search will ignore case.
|
|
218
218
|
|
219
219
|
pg_search [{ :columns => %w{employees.full_name companies.name} }, :ignore_case => true ]
|
220
220
|
|
221
|
-
|
221
|
+
If you set `prefix_matching` attribute to true - lexemes in a tsquery can will be labeled with * to specify prefix matching.
|
222
|
+
|
223
|
+
pg_search [{ :columns => %w{employees.full_name companies.name} }, :prefix_matching => true ]
|
224
|
+
|
225
|
+
Options like `unaccent`, `any_word`, `ignore_case`, `prefix_matching` can be set to be used only on query or document. In Example if you use specific column that already has unaccented and lowercased text with GIN/GIST index and do not want to additionally use `unaccent` or `ignore_case` functions on that column(because this will cause index not to work) -you can disable those options. Ex.
|
222
226
|
|
223
227
|
pg_search [{ :columns => %w{employees.full_name} }, :ignore_case => {query: true} ]
|
224
228
|
|
data/lib/mincer.rb
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
require 'ostruct'
|
2
2
|
require 'mincer/version'
|
3
|
-
require 'mincer/core_ext/string'
|
4
3
|
require 'mincer/config'
|
5
4
|
require 'mincer/base'
|
6
5
|
|
@@ -10,7 +9,7 @@ module Mincer
|
|
10
9
|
end
|
11
10
|
|
12
11
|
def self.postgres?
|
13
|
-
self.connection.
|
12
|
+
self.connection.adapter_name == 'PostgreSQL' rescue false
|
14
13
|
end
|
15
14
|
|
16
15
|
def self.connection
|
@@ -13,7 +13,7 @@ module Mincer
|
|
13
13
|
|
14
14
|
def to_json
|
15
15
|
if dump_supported?
|
16
|
-
result = Mincer.connection.
|
16
|
+
result = Mincer.connection.select_all(json_query).first['json']
|
17
17
|
return result unless @options[:singularize]
|
18
18
|
return (result[1..-2].presence || '{}') unless @options[:root]
|
19
19
|
(result.sub('[', '').sub(/(\])}$/, '}').presence || '{}')
|
@@ -43,6 +43,9 @@ module Mincer
|
|
43
43
|
# Query for basic json generation. Ex: [{'id': 1}, {...}]
|
44
44
|
def basic_json_query(root = 'json', meta = false)
|
45
45
|
meta_sql = if meta
|
46
|
+
if meta.is_a?(Hash) && meta[:total_count]
|
47
|
+
@mincer.relation.instance_variable_set(:@total_count, meta[:total_count])
|
48
|
+
end
|
46
49
|
", #{@mincer.total_pages} AS total_pages, #{@mincer.total_count} AS total_count, #{@mincer.current_page} AS current_page, #{@mincer.limit_value} AS per_page"
|
47
50
|
else
|
48
51
|
''
|
@@ -47,7 +47,7 @@ module Mincer
|
|
47
47
|
join_expressions(conditions, :+)
|
48
48
|
end.compact
|
49
49
|
rank = join_expressions(search_statements_conditions, :+).try(:to_sql)
|
50
|
-
"#{rank} DESC" if rank.present?
|
50
|
+
Arel.sql("#{rank} DESC") if rank.present?
|
51
51
|
end
|
52
52
|
|
53
53
|
def pg_search_engines(args, search_statement)
|
@@ -53,8 +53,11 @@ module Mincer
|
|
53
53
|
|
54
54
|
def ts_query_for(search_statement)
|
55
55
|
terms_delimiter = search_statement.options[:any_word] ? '|' : '&'
|
56
|
-
|
57
|
-
|
56
|
+
tsquery = search_statement.terms.map do |term|
|
57
|
+
_term = search_statement.options[:prefix_matching] ? "#{term}:*" : term
|
58
|
+
sanitize_string_quoted(_term, search_statement.sanitizers(:query)).to_sql
|
59
|
+
end.join(" || ' #{terms_delimiter} ' || ")
|
60
|
+
Arel::Nodes::NamedFunction.new('to_tsquery', [quote(search_statement.dictionary), Arel.sql(tsquery)])
|
58
61
|
end
|
59
62
|
end
|
60
63
|
|
data/lib/mincer/version.rb
CHANGED
data/mincer.gemspec
CHANGED
@@ -22,7 +22,7 @@ Gem::Specification.new do |spec|
|
|
22
22
|
|
23
23
|
spec.add_development_dependency 'bundler'
|
24
24
|
spec.add_development_dependency 'rake'
|
25
|
-
spec.add_development_dependency 'pg'
|
25
|
+
spec.add_development_dependency 'pg'#, '~> 0.18'
|
26
26
|
spec.add_development_dependency 'sqlite3'
|
27
27
|
spec.add_development_dependency 'kaminari'
|
28
28
|
spec.add_development_dependency 'will_paginate'
|
@@ -15,7 +15,7 @@ describe ::Mincer::Processors::PgJsonDumper::Processor do
|
|
15
15
|
|
16
16
|
it 'dumps data via postgres' do
|
17
17
|
query = subject.new(ActiveRecordModel)
|
18
|
-
ActiveRecord::Base.connection.should_receive(:
|
18
|
+
ActiveRecord::Base.connection.should_receive(:select_all).and_call_original
|
19
19
|
json_string = query.to_json
|
20
20
|
json_string.should be_a(String)
|
21
21
|
json_hash = JSON.parse(json_string)
|
@@ -29,7 +29,7 @@ describe ::Mincer::Processors::PgJsonDumper::Processor do
|
|
29
29
|
context 'when root option is passed' do
|
30
30
|
it 'puts responce inside under root key' do
|
31
31
|
query = subject.new(ActiveRecordModel)
|
32
|
-
ActiveRecord::Base.connection.should_receive(:
|
32
|
+
ActiveRecord::Base.connection.should_receive(:select_all).and_call_original
|
33
33
|
json_string = query.to_json(root: 'items')
|
34
34
|
json_string.should be_a(String)
|
35
35
|
json_hash = JSON.parse(json_string)
|
@@ -56,7 +56,7 @@ describe ::Mincer::Processors::PgJsonDumper::Processor do
|
|
56
56
|
|
57
57
|
it 'dumps data via calling super' do
|
58
58
|
query = subject.new(ActiveRecordModel)
|
59
|
-
ActiveRecord::Base.connection.should_not_receive(:
|
59
|
+
ActiveRecord::Base.connection.should_not_receive(:select_all)
|
60
60
|
json_string = query.to_json
|
61
61
|
json_string.should be_nil
|
62
62
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mincer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.20
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alex Krasinsky
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-03-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -142,7 +142,6 @@ files:
|
|
142
142
|
- lib/mincer/action_view/sort_helper.rb
|
143
143
|
- lib/mincer/base.rb
|
144
144
|
- lib/mincer/config.rb
|
145
|
-
- lib/mincer/core_ext/string.rb
|
146
145
|
- lib/mincer/processors/cache_digest/processor.rb
|
147
146
|
- lib/mincer/processors/helpers.rb
|
148
147
|
- lib/mincer/processors/pagination/processor.rb
|
@@ -195,8 +194,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
195
194
|
- !ruby/object:Gem::Version
|
196
195
|
version: '0'
|
197
196
|
requirements: []
|
198
|
-
|
199
|
-
rubygems_version: 2.4.5.1
|
197
|
+
rubygems_version: 3.0.6
|
200
198
|
signing_key:
|
201
199
|
specification_version: 4
|
202
200
|
summary: ActiveRecord::Relation wrapper for pagination, order, json, search, cache_digest
|