workarea-core 3.4.28 → 3.4.29

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: a8439c1a91cb856c912b1d2e905b0febc658cfa4d8aa2e0d284783f52e4b02e0
4
- data.tar.gz: ec47357ec28e16a43e06dbbfa1ad1323767dae291c199d715d5241fa5d54d611
3
+ metadata.gz: 293a8eac548e651d077a238236f6e127e2bd136ec50139fbe8ad18dcda7adfb7
4
+ data.tar.gz: f8173cfae95ed2e11933669e4c4aedd086edc1dff489e18ed69c2bf0aeddcede
5
5
  SHA512:
6
- metadata.gz: 1b7801af7aa2e4f98ac24a0e8f53fae358e0ebdbd8504766144c5dc6df7c0e478fd3c73fbf2b0996fb38ad131f72137466cecec2cfa8c6ee3ff0b098dce465df
7
- data.tar.gz: 0de8df6aae608882554a3280eaa2d6f473ac181c68b8356aa9bf4ac9fefc0443d98172c85af55e8de71f0ea96e0cb36acd2000b94b1ebbb9f3c46956b9c6b0f9
6
+ metadata.gz: 2cb7c1571e058e31fef6d5cce6d65e3e3afe1f3830175bb086c735eabf54e70f71399a757c5312196cfe9321b0cad0b1241dca1745d2ad99a21601079353e8ff
7
+ data.tar.gz: 72164a859e0a2cf841ecb12fac24ea670b0057209d1fab1e31d45d91399729727ad9eb06212a21f5adc3c917b2d1df33c6a1518d23b4a0c8bf9f7dd33d19887a
@@ -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)
@@ -1283,6 +1283,12 @@ module Workarea
1283
1283
  'Workarea::Catalog::Category' => 7,
1284
1284
  'Workarea::Navigation::Menu' => 1_000
1285
1285
  }
1286
+
1287
+ # The max number of types of results that will show in the admin jump to
1288
+ config.jump_to_type_limit = 5
1289
+
1290
+ # The number of results that will show per-type in the admin jump to
1291
+ config.jump_to_results_per_type = 5
1286
1292
  end
1287
1293
  end
1288
1294
  end
@@ -2,7 +2,7 @@ module Workarea
2
2
  module VERSION
3
3
  MAJOR = 3
4
4
  MINOR = 4
5
- PATCH = 28
5
+ PATCH = 29
6
6
  PRE = nil
7
7
 
8
8
  STRING = [MAJOR, MINOR, PATCH, PRE].compact.join('.')
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.4.28
4
+ version: 3.4.29
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