From 840a65116bae6a68454f6394a9e049dc708b9548 Mon Sep 17 00:00:00 2001 From: Ahmed El-Helw Date: Thu, 25 Aug 2016 12:49:43 -0700 Subject: [PATCH] Don't return font numbers in search api (#76) When we do a search, we also search the fonts - we use the information from these to properly highlight the results. While this is all good, we should not be returning these results back from the api. This patch fixes that by returning a nil from that block, and then compacting the match array in order to remove the nil element before returning. Fixes #63. --- app/models/search/results.rb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/models/search/results.rb b/app/models/search/results.rb index 64613fc3..c3cc1f27 100644 --- a/app/models/search/results.rb +++ b/app/models/search/results.rb @@ -70,12 +70,13 @@ def aggregation_records ayah_result[:ayah][:words].find{|word| word['word_id'] == id.to_i}[:highlight] = word_id_array.first end end + nil + else + hash end - - hash end - ayah_result.merge!(match: match) + ayah_result.merge!(match: match.compact) ayah_result end