Provide second rake task that updates text extractions even for those that have already been extracted.

This commit is contained in:
Wieland Lindenthal
2018-02-01 16:22:37 +01:00
parent 5ffbba0cd7
commit 7636aede9c
3 changed files with 17 additions and 5 deletions
+8 -1
View File
@@ -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
```
+8 -3
View File
@@ -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