about summary refs log tree commit diff
path: root/app/services
diff options
context:
space:
mode:
Diffstat (limited to 'app/services')
-rw-r--r--app/services/account_search_service.rb10
-rw-r--r--app/services/tag_search_service.rb11
2 files changed, 11 insertions, 10 deletions
diff --git a/app/services/account_search_service.rb b/app/services/account_search_service.rb
index 01caaefa9..40c5f8590 100644
--- a/app/services/account_search_service.rb
+++ b/app/services/account_search_service.rb
@@ -42,11 +42,9 @@ class AccountSearchService < BaseService
     return [] if limit_for_non_exact_results.zero?
 
     @search_results ||= begin
-      if Chewy.enabled?
-        from_elasticsearch
-      else
-        from_database
-      end
+      results = from_elasticsearch if Chewy.enabled?
+      results ||= from_database
+      results
     end
   end
 
@@ -92,6 +90,8 @@ class AccountSearchService < BaseService
     ActiveRecord::Associations::Preloader.new.preload(records, :account_stat)
 
     records
+  rescue Faraday::ConnectionFailed, Parslet::ParseFailed
+    nil
   end
 
   def reputation_score_function
diff --git a/app/services/tag_search_service.rb b/app/services/tag_search_service.rb
index 64dd76bb7..5cb0eea7a 100644
--- a/app/services/tag_search_service.rb
+++ b/app/services/tag_search_service.rb
@@ -6,11 +6,10 @@ class TagSearchService < BaseService
     @offset = options[:offset].to_i
     @limit  = options[:limit].to_i
 
-    if Chewy.enabled?
-      from_elasticsearch
-    else
-      from_database
-    end
+    results = from_elasticsearch if Chewy.enabled?
+    results ||= from_database
+
+    results
   end
 
   private
@@ -74,6 +73,8 @@ class TagSearchService < BaseService
     }
 
     TagsIndex.query(query).filter(filter).limit(@limit).offset(@offset).objects.compact
+  rescue Faraday::ConnectionFailed, Parslet::ParseFailed
+    nil
   end
 
   def from_database