grape-listing 1.1.11 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 42151a397fe1355931f6dcd0c63fb939c3243946fd74d740917a7baade052cc3
4
- data.tar.gz: a05d65e9c19e8e6a842b4e6de0d35beababfab88199542a1f1c91c0bc4fddf60
3
+ metadata.gz: bb778ae3f53f8f3703261e1eb87f7c35ff443841630966a81ce6d30a85927101
4
+ data.tar.gz: a20c1c499e21021c1b4947f7e4cc2a44bb966ee498d3231503dcedb6e378a1bd
5
5
  SHA512:
6
- metadata.gz: 1aff012b41a15c19efe96e9256901cfd865184f7db29bf39b1e28bbac9aa3b9a631f636d1fb5c14820a3e6dd599422c4060b662bd63b977f092fd3a4d482af06
7
- data.tar.gz: 1d958d8fdbfc3035f7518cb560262ff04a0dea151f42dd160af7c1c88dd1d029060c9711f73f16f16092b73bf189ad865b5e77d0f6a889bd5ab2f9b84d5e50af
6
+ metadata.gz: '084ce80e719db7ea9e9f0d583f47777e0ec830f490b209f989aa2ff9ac23ea7827dd5a0e077f89fdb10192f2978fbbbafef037ee806a2808ae30eff62f5f648c'
7
+ data.tar.gz: 34ceba64869852554488007521cb94fc171180b28e2da1aaea6f0cb0febafe5a2a87a47d05c8aa4958ee44b42f2f584d0e547585ee2820bd13e4104c6ff18839
@@ -55,7 +55,7 @@ module GrapeListing
55
55
  value = "%#{value}%" if operator == 'ilike' && value.present?
56
56
 
57
57
  # проверка мульти-поиска по параметру с массивом
58
- if operator == 'multi' && !value.blank?
58
+ if value.is_a?(Array)
59
59
  operator = 'IN'
60
60
  value = "(#{value.map { |i| "'#{i}'" }.join(', ')})"
61
61
  end
@@ -67,12 +67,6 @@ module GrapeListing
67
67
  operator = operator == 'min' ? '>=' : '<='
68
68
  end
69
69
 
70
- # check array operator
71
- if operator == 'array' && value.present?
72
- operator = '='
73
- value = "{#{value}}"
74
- end
75
-
76
70
  [operator, value]
77
71
  end
78
72
 
@@ -46,9 +46,20 @@ module GrapeListing
46
46
  end
47
47
 
48
48
  def caching_entity_representation(record)
49
- key = "#{@grape_entity}:#{record.id}"
49
+ # формирование ключа кеширования с параметрами
50
+ params_string = Rack::Utils.build_query(@params.except('offset', 'page'))
51
+ key = "#{@grape_entity}:#{record.id}:#{params_string}"
52
+ enc_key = Digest::MD5.hexdigest(key)
50
53
 
51
- GrapeListing.cache.fetch(key) do
54
+ # опции кеширования
55
+ opts =
56
+ if @caching.is_a?(ActiveSupport::Duration)
57
+ { expires_in: @caching }
58
+ else
59
+ {}
60
+ end
61
+
62
+ GrapeListing.cache.fetch(enc_key, opts) do
52
63
  @grape_entity.represent(record, @entity_opts).as_json
53
64
  end
54
65
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: grape-listing
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.11
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Павел Бабин
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-07-02 00:00:00.000000000 Z
11
+ date: 2024-09-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionpack