mirror of
https://github.com/opf/openproject.git
synced 2026-06-14 03:30:14 +00:00
Provide second rake task that updates text extractions even for those that have already been extracted.
This commit is contained in:
@@ -189,10 +189,17 @@ class Attachment < ActiveRecord::Base
|
||||
|
||||
# Extract the fulltext of any attachments where fulltext is still nil.
|
||||
# This runs inline and not in a asynchronous worker.
|
||||
def self.extract_fulltext
|
||||
def self.extract_fulltext_where_missing
|
||||
Attachment.where(fulltext: nil).pluck(:id).each do |id|
|
||||
job = ExtractFulltextJob.new(id)
|
||||
job.perform
|
||||
end
|
||||
end
|
||||
|
||||
def self.force_extract_fulltext
|
||||
Attachment.pluck(:id).each do |id|
|
||||
job = ExtractFulltextJob.new(id)
|
||||
job.perform
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -230,7 +230,7 @@ To make sure that all work package attachments are indexed, so that their conten
|
||||
run:
|
||||
|
||||
```bash
|
||||
[openproject@debian]# RAILS_ENV="production" rake attachments:extract_fulltext
|
||||
[openproject@debian]# RAILS_ENV="production" rake extract_fulltext_where_missing
|
||||
```
|
||||
|
||||
|
||||
|
||||
@@ -27,7 +27,12 @@
|
||||
# See doc/COPYRIGHT.rdoc for more details.
|
||||
#++
|
||||
|
||||
desc 'Makes existing attachments fulltext searchable'
|
||||
task extract_fulltext: :environment do
|
||||
Attachment.extract_fulltext
|
||||
desc 'Extracts fulltext of attachments that were not extracted yet and provide it for attachment filter.'
|
||||
task extract_fulltext_where_missing: :environment do
|
||||
Attachment.extract_fulltext_where_missing
|
||||
end
|
||||
|
||||
desc 'Extracts fulltext of all attachments and provide it for attachment filter even if that attachment has been extracted before.'
|
||||
task force_extract_fulltext: :environment do
|
||||
Attachment.force_extract_fulltext
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user