alchemy-pg_search 6.0.0 → 6.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: '009bedc83da970afa4e20ea64375695711b50ef37027b4e4cbe08a7add274070'
4
- data.tar.gz: c324b6915704b0ef189d539510d57ff80962be5f6244907bbfd9d82e0d13eec8
3
+ metadata.gz: c1ae33c7df0a9edd59d4582f0570418ddef3c60b5cd51dfade9da06fff5c5ccf
4
+ data.tar.gz: 6790580e147d7fe1153593d5a9c7c7fe73d7f0f49ebf0fb86caca618dba785f2
5
5
  SHA512:
6
- metadata.gz: 0eda59775b10f840a97362c244beb387e259e104d18f03e855984ea15437649d78c1a397a4a2f443e62c62bbd74f42288b77ce7ede6401d090ae28b1d3844d06
7
- data.tar.gz: 6245d3b156a31fe0459fc9372de9c3ffc8ab7f123dd717402a7dc3aeb206876912069f88ae4d20a127039ee1754d45f87c6391633490f8363dde101a2cb8fb10
6
+ metadata.gz: c9f7c4b91444eb8aed240c104fd7c44a1b12f6751128586a7aa310be5565996bd0e60e2bf874a57c2fcbb38b2e094c4d56fa8db5ed2f4256dfc98ddb50815dc7
7
+ data.tar.gz: 49296c5f3ed08f8dceedc9fd77664757c9096fa92898c40db6e7714c88c2802491c21a58e2d6f80a86b946b36347ce7c0e41ac50c83a35be4a4cb19345a455fd
data/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Changelog
2
2
 
3
+ ## [v6.1.0](https://github.com/AlchemyCMS/alchemy-pg_search/tree/v6.1.0) (2024-12-13)
4
+
5
+ [Full Changelog](https://github.com/AlchemyCMS/alchemy-pg_search/compare/v6.0.0...v6.1.0)
6
+
7
+ **Merged pull requests:**
8
+
9
+ - Use PgSearch::Document.rebuild for page reindex [\#63](https://github.com/AlchemyCMS/alchemy-pg_search/pull/63) ([sascha-karnatz](https://github.com/sascha-karnatz))
10
+
3
11
  ## [v6.0.0](https://github.com/AlchemyCMS/alchemy-pg_search/tree/v6.0.0) (2024-12-03)
4
12
 
5
13
  [Full Changelog](https://github.com/AlchemyCMS/alchemy-pg_search/compare/v5.2.0...v6.0.0)
@@ -6,24 +6,18 @@ module Alchemy::PgSearch::PageExtension
6
6
  base.after_save :remove_unpublished_page
7
7
  base.multisearchable(
8
8
  against: [
9
- :meta_description,
10
- :meta_keywords,
11
9
  :name,
10
+ :searchable_content
12
11
  ],
13
12
  additional_attributes: ->(page) { { page_id: page.id, searchable_created_at: page.public_on } },
14
13
  if: :searchable?,
15
14
  )
16
15
  end
17
16
 
18
- def searchable?
19
- (definition.key?(:searchable) ? definition[:searchable] : true) &&
20
- searchable && public? && !layoutpage?
21
- end
22
-
23
17
  private
24
18
 
25
19
  def remove_unpublished_page
26
- Alchemy::PgSearch.remove_page(self) unless searchable?
20
+ ::PgSearch::Document.delete_by(page_id: id) unless searchable?
27
21
  end
28
22
  end
29
23
 
@@ -10,6 +10,10 @@ module Alchemy::Search::ElementExtension
10
10
  def searchable?
11
11
  searchable && public? && page.searchable? && page_version.public?
12
12
  end
13
+
14
+ def searchable_content
15
+ ingredients.select(&:searchable?).map(&:searchable_content).join(" ").squish
16
+ end
13
17
  end
14
18
 
15
19
  Alchemy::Element.prepend(Alchemy::Search::ElementExtension)
@@ -5,6 +5,10 @@ module Alchemy::Search::PageExtension
5
5
  (definition.key?(:searchable) ? definition[:searchable] : true) &&
6
6
  searchable && public? && !layoutpage?
7
7
  end
8
+
9
+ def searchable_content
10
+ all_elements.includes(ingredients: {element: :page}).map(&:searchable_content).join(" ")
11
+ end
8
12
  end
9
13
 
10
14
  Alchemy::Page.prepend(Alchemy::Search::PageExtension)
@@ -2,7 +2,7 @@ module Alchemy
2
2
  module PgSearch
3
3
  class IndexPageJob < BaseJob
4
4
  def perform(page)
5
- PgSearch.index_page(page)
5
+ page.update_pg_search_document
6
6
  end
7
7
  end
8
8
  end
@@ -1,5 +1,5 @@
1
1
  module Alchemy
2
2
  module PgSearch
3
- VERSION = "6.0.0"
3
+ VERSION = "6.1.0"
4
4
  end
5
5
  end
@@ -17,37 +17,13 @@ module Alchemy
17
17
  extend Config
18
18
 
19
19
  ##
20
- # index all supported Alchemy pages
21
- def self.rebuild
22
- ActiveRecord::Base.transaction do
23
- ::PgSearch::Document.delete_all
24
- Alchemy::Page.all.each{ |page| index_page(page) }
25
- end
26
- end
27
-
28
- ##
29
- # remove the whole index for the page
30
- #
31
- # @param page [Alchemy::Page]
32
- def self.remove_page(page)
33
- ::PgSearch::Document.delete_by(page_id: page.id)
34
- end
35
-
36
- ##
37
- # index a single page and indexable ingredients
38
- #
39
- # @param page [Alchemy::Page]
40
- def self.index_page(page)
41
- page.update_pg_search_document
42
-
43
- document = page.pg_search_document
44
- return if document.nil?
45
-
46
- ingredient_content = page.all_elements.includes(ingredients: {element: :page}).map do |element|
47
- element.ingredients.select { |i| i.searchable? }.map(&:searchable_content).join(" ")
48
- end.join(" ")
49
-
50
- document.update_column(:content, "#{document.content} #{ingredient_content}".squish)
20
+ # Reindex all supported Alchemy pages
21
+ def self.rebuild(clean_up: true, transactional: true)
22
+ ::PgSearch::Multisearch.rebuild(
23
+ Alchemy::Page,
24
+ clean_up: clean_up,
25
+ transactional: transactional
26
+ )
51
27
  end
52
28
 
53
29
  ##
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: alchemy-pg_search
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.0.0
4
+ version: 6.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thomas von Deyen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-12-03 00:00:00.000000000 Z
11
+ date: 2024-12-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: alchemy_cms