workarea-core 3.5.6 → 3.5.7

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: bb5020f2786f93ffc74cafd5726c8c279950df5645b73a4de0e53b8e5347bf12
4
- data.tar.gz: f1f6c1f0e95915279dbd825021d1ac4ed6461d99f6f3746daadcdd28ef89a2a7
3
+ metadata.gz: 26dc982f98d5ae00a8d3299b322cd6eb897329888c169a7a035e0bafad3be1e8
4
+ data.tar.gz: f3b5ae6b3bddb68b0e3d5b5c303e565e69ff812e165371e35285cd3ce04d334e
5
5
  SHA512:
6
- metadata.gz: 97c8c17c68a43238a384073d9b9f3365635cf4577cd7e2d11fae11476548b69840eb903bcb4aabcffe07b23b8f93e12fc7724a5b809df5ed772415050ac41125
7
- data.tar.gz: 395b8ae08cb06235e4a60e7a9cbac02c30b9db5022863903ae8b3affee561ecc5b204e0c492f41983df5ac0b224c17fce79cb1f0225f5ea518b4f47428f6dfdd
6
+ metadata.gz: 31ad3ba0206fb6c815e6af2d4af9b572dbefec26460adfa14191279f9bd8098c462eb21b61139a0003ba775ae0b6e65294745b312ba776cd44cb55931221d40f
7
+ data.tar.gz: 8ffe28be251fddeba16e2f4964ca716ea8f759d171154529414e3b826accc1a709acb15f0374916d4ff2260f64c21acdd1a44b71687bb93fadec4bc626e81e11
@@ -5,27 +5,39 @@ module Workarea
5
5
 
6
6
  def self.jump_to(params, size = Workarea.config.default_admin_jump_to_result_count)
7
7
  query = {
8
- query: {
9
- match_phrase_prefix: {
10
- jump_to_search_text: {
11
- query: params[:q],
12
- max_expansions: 10
8
+ aggs: {
9
+ grouped_by_type: {
10
+ filter: {
11
+ match_phrase_prefix: {
12
+ jump_to_search_text: {
13
+ query: params[:q],
14
+ max_expansions: 10
15
+ }
16
+ }
17
+ },
18
+ aggs: {
19
+ type: {
20
+ terms: { field: 'facets.type', size: Workarea.config.jump_to_type_limit },
21
+ aggs: { top: { top_hits: { size: Workarea.config.jump_to_results_per_type } } }
22
+ }
13
23
  }
14
24
  }
15
- },
16
- size: size,
17
- sort: [{ jump_to_position: :asc }]
25
+ }
18
26
  }
19
27
 
20
- search(query)['hits']['hits'].map do |result|
21
- {
22
- label: result['_source']['jump_to_text'],
23
- type: result['_source']['facets']['type'],
24
- model_class: result['_source']['model_class'],
25
- route_helper: result['_source']['jump_to_route_helper'],
26
- to_param: result['_source']['jump_to_param']
27
- }
28
- end
28
+ aggregation = search(query)['aggregations']['grouped_by_type']['type']
29
+ aggregation['buckets']
30
+ .reduce([]) { |m, b| m + b['top']['hits']['hits'] }
31
+ .sort_by { |r| [r['_source']['jump_to_position'], r['_score']] }
32
+ .map do |result|
33
+ {
34
+ label: result['_source']['jump_to_text'],
35
+ type: result['_source']['facets']['type'],
36
+ model_class: result['_source']['model_class'],
37
+ route_helper: result['_source']['jump_to_route_helper'],
38
+ to_param: result['_source']['jump_to_param']
39
+ }
40
+ end
29
41
  end
30
42
 
31
43
  def self.for(model)
@@ -1291,6 +1291,12 @@ module Workarea
1291
1291
  'Workarea::Catalog::Category' => 7,
1292
1292
  'Workarea::Navigation::Menu' => 1_000
1293
1293
  }
1294
+
1295
+ # The max number of types of results that will show in the admin jump to
1296
+ config.jump_to_type_limit = 5
1297
+
1298
+ # The number of results that will show per-type in the admin jump to
1299
+ config.jump_to_results_per_type = 5
1294
1300
  end
1295
1301
  end
1296
1302
  end
@@ -2,7 +2,7 @@ module Workarea
2
2
  module VERSION
3
3
  MAJOR = 3
4
4
  MINOR = 5
5
- PATCH = 6
5
+ PATCH = 7
6
6
  PRE = nil
7
7
  STRING = [MAJOR, MINOR, PATCH, PRE].compact.join('.')
8
8
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: workarea-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.5.6
4
+ version: 3.5.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Crouse
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-03-03 00:00:00.000000000 Z
11
+ date: 2020-03-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler