From e0908fb85f9c208e0f9b681f2344451c64388ccc Mon Sep 17 00:00:00 2001 From: zmagod Date: Wed, 30 May 2018 18:18:09 +0200 Subject: [PATCH 1/2] adds asset_text_data to global search options --- config/initializers/constants.rb | 1 + config/initializers/extends.rb | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/config/initializers/constants.rb b/config/initializers/constants.rb index 2f8ee2518..b264f4162 100644 --- a/config/initializers/constants.rb +++ b/config/initializers/constants.rb @@ -176,6 +176,7 @@ class Constants #============================================================================= TEXT_EXTRACT_FILE_TYPES = [ + 'application/msword', 'application/pdf', 'application/rtf', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', diff --git a/config/initializers/extends.rb b/config/initializers/extends.rb index 80f3e4273..c7c0492b5 100644 --- a/config/initializers/extends.rb +++ b/config/initializers/extends.rb @@ -53,12 +53,13 @@ class Extends # are only supported REPOSITORY_EXTRA_SEARCH_ATTR = ['repository_text_values.data', 'repository_list_items.data', - 'assets.file_file_name'] + 'assets.file_file_name', + 'asset_text_data.data'] # Array of includes used in search query for repository rows REPOSITORY_SEARCH_INCLUDES = [:repository_text_value, repository_list_value: :repository_list_item, - repository_asset_value: :asset] + repository_asset_value: { asset: :asset_text_datum }] # List of implemented core API versions API_VERSIONS = ['20170715'] From 3da098cb605eddc6188b12040a871250e8988322 Mon Sep 17 00:00:00 2001 From: zmagod Date: Thu, 31 May 2018 09:42:57 +0200 Subject: [PATCH 2/2] fixes the issue with extraction of text from file [fixes SCI-2417] --- app/models/asset.rb | 7 +++---- config/initializers/constants.rb | 1 + config/initializers/extends.rb | 5 ++--- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/app/models/asset.rb b/app/models/asset.rb index 055db8873..61b519ddb 100644 --- a/app/models/asset.rb +++ b/app/models/asset.rb @@ -199,7 +199,8 @@ class Asset < ApplicationRecord Rails.logger.info "Asset #{id}: Creating extract text job" # The extract_asset_text also includes # estimated size calculation - delay(queue: :assets).extract_asset_text(team) + delay(queue: :assets, run_at: 20.minutes.from_now) + .extract_asset_text(team) else # Update asset's estimated size immediately update_estimated_size(team) @@ -207,9 +208,7 @@ class Asset < ApplicationRecord end def extract_asset_text(team = nil) - if file.blank? - return - end + return if file.blank? begin file_path = file.path diff --git a/config/initializers/constants.rb b/config/initializers/constants.rb index b264f4162..f4ade5661 100644 --- a/config/initializers/constants.rb +++ b/config/initializers/constants.rb @@ -177,6 +177,7 @@ class Constants TEXT_EXTRACT_FILE_TYPES = [ 'application/msword', + 'application/vnd.openxmlformats-officedocument.wordprocessingml.template', 'application/pdf', 'application/rtf', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', diff --git a/config/initializers/extends.rb b/config/initializers/extends.rb index c7c0492b5..80f3e4273 100644 --- a/config/initializers/extends.rb +++ b/config/initializers/extends.rb @@ -53,13 +53,12 @@ class Extends # are only supported REPOSITORY_EXTRA_SEARCH_ATTR = ['repository_text_values.data', 'repository_list_items.data', - 'assets.file_file_name', - 'asset_text_data.data'] + 'assets.file_file_name'] # Array of includes used in search query for repository rows REPOSITORY_SEARCH_INCLUDES = [:repository_text_value, repository_list_value: :repository_list_item, - repository_asset_value: { asset: :asset_text_datum }] + repository_asset_value: :asset] # List of implemented core API versions API_VERSIONS = ['20170715']