dina 1.3.0.0 → 1.3.1.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: 36ae9a46adaaf1a545511c102afbc5bada1c3ad4632273672253f9191e347459
4
- data.tar.gz: 67c1631fad9d7ebb3469a063fc6b22e1d6c9d720a8abe6804ae35c7d4dd83848
3
+ metadata.gz: 3d466686f44b5d2e0850a05283bef73ccf71bb25da366a1d80aec8945d6e0fd2
4
+ data.tar.gz: b250f06e97f384449790007f2f4b6588fa634186b7853e4a67508fa049e2ab0d
5
5
  SHA512:
6
- metadata.gz: ba219ae94560f594838864568429f8c84e4bf86a8c4396a0fd142c8803a0aea03f0da864b7bb9b44f700234d1da7dfbf9b75e6033ad1690fb5b13e69785700b1
7
- data.tar.gz: cd564fa3198356107742862c2cc7d45b4c32dace7c3684117ccb9e29d97e066bb0c6fb60dd5ca8aa388afe66c11203fa9d6558efc9f68ee82824536aa076ef4d
6
+ metadata.gz: e3e4afce48d934ddb4b3ed5f1d4b0fd6c474f38cdb2ef7e7259611a02910f66cd7561d71cb85b858692d0a87e71efa5e5a0b7d005e2ba311a7b76da3f705fcfb
7
+ data.tar.gz: 7546f5bb55aeb366aed09ed9107a1e6fc26bb2aa7fa7ada784d4d73c2ecb92940803ee97dde61290b10b4313f582ceede57b311840c8d081ac01ebc152366595
@@ -4,11 +4,11 @@ require_rel 'search_connection'
4
4
  #TODO: requires testing, likely failing
5
5
 
6
6
  module Dina
7
- class SearchAutocomplete < BaseModel
7
+ class SearchAutoComplete < BaseModel
8
8
 
9
9
  self.connection_class = SearchConnection
10
10
 
11
- custom_endpoint :execute, on: :collection, request_method: :post
11
+ custom_endpoint :execute, on: :collection, request_method: :get
12
12
 
13
13
  def self.endpoint_path
14
14
  "search-api/search-ws/"
@@ -34,11 +34,12 @@ module Dina
34
34
  end
35
35
 
36
36
  def run(request_method, path, params: nil, headers: {}, body: nil)
37
- #TODO: works for search class, but likely failing for autocomplete, count, and mapping
38
- params = {
39
- indexName: index_name(index: body[:index])
40
- }
41
37
  path.slice!("/execute")
38
+ if params && params.has_key?(:index)
39
+ params.merge!(indexName: index_name(index: params[:index]))
40
+ elsif body && body.has_key?(:index)
41
+ params = { indexName: index_name(index: body[:index]) }
42
+ end
42
43
  payload = JSON.generate(body[:payload]) rescue ""
43
44
 
44
45
  response = faraday.run_request(request_method, path, body, headers) do |request|
@@ -48,7 +49,16 @@ module Dina
48
49
  end
49
50
 
50
51
  attributes = response.body.dup
51
- response.body["meta"] = {}
52
+ meta = {}
53
+ if attributes.has_key?("hits")
54
+ #TODO: does not work with SearchAutoComplete because response is different from Search
55
+ meta["count"] = attributes["hits"]["total"]["value"] rescue 0
56
+ elsif attributes.has_key?("count")
57
+ meta["count"] = attributes["count"]
58
+ elsif attributes.has_key?("attributes")
59
+ meta = attributes
60
+ end
61
+ response.body["meta"] = meta
52
62
  response.body["errors"] = []
53
63
  response.body["data"] = attributes["hits"]["hits"].map{|d| d["_source"]["data"]} rescue []
54
64
  response
@@ -1,8 +1,6 @@
1
1
  require_rel '../models/base_model'
2
2
  require_rel 'search_connection'
3
3
 
4
- #TODO: requires testing, likely failing
5
-
6
4
  module Dina
7
5
  class SearchCount < BaseModel
8
6
 
@@ -1,8 +1,6 @@
1
1
  require_rel '../models/base_model'
2
2
  require_rel 'search_connection'
3
3
 
4
- #TODO: requires testing, likely failing
5
-
6
4
  module Dina
7
5
  class SearchMapping < BaseModel
8
6
 
data/lib/dina/version.rb CHANGED
@@ -3,7 +3,7 @@ module Dina
3
3
 
4
4
  MAJOR = 1
5
5
  MINOR = 3
6
- PATCH = 0
6
+ PATCH = 1
7
7
  BUILD = 0
8
8
 
9
9
  def self.version
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dina
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0.0
4
+ version: 1.3.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - David P. Shorthouse
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2023-12-04 00:00:00.000000000 Z
12
+ date: 2023-12-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: json_api_client