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 +4 -4
- data/CHANGELOG.md +8 -0
- data/app/extensions/alchemy/pg_search/page_extension.rb +2 -8
- data/app/extensions/alchemy/search/element_extension.rb +4 -0
- data/app/extensions/alchemy/search/page_extension.rb +4 -0
- data/app/jobs/alchemy/pg_search/index_page_job.rb +1 -1
- data/lib/alchemy/pg_search/version.rb +1 -1
- data/lib/alchemy-pg_search.rb +7 -31
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c1ae33c7df0a9edd59d4582f0570418ddef3c60b5cd51dfade9da06fff5c5ccf
|
4
|
+
data.tar.gz: 6790580e147d7fe1153593d5a9c7c7fe73d7f0f49ebf0fb86caca618dba785f2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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)
|
data/lib/alchemy-pg_search.rb
CHANGED
@@ -17,37 +17,13 @@ module Alchemy
|
|
17
17
|
extend Config
|
18
18
|
|
19
19
|
##
|
20
|
-
#
|
21
|
-
def self.rebuild
|
22
|
-
|
23
|
-
::
|
24
|
-
|
25
|
-
|
26
|
-
|
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.
|
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-
|
11
|
+
date: 2024-12-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: alchemy_cms
|