[GMG-Devel] [PATCH 49/83] Show only unique results.

Alon Levy alon at pobox.com
Tue Feb 25 14:58:31 EST 2014


From: Praveen Kumar <praveen97uma at gmail.com>

---
 mediagoblin/plugins/search/indices.py | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/mediagoblin/plugins/search/indices.py b/mediagoblin/plugins/search/indices.py
index d62548b..b8003ca 100644
--- a/mediagoblin/plugins/search/indices.py
+++ b/mediagoblin/plugins/search/indices.py
@@ -24,10 +24,11 @@ class MediaEntrySearchIndex(SearchIndex):
             'css_id': self.css_id,
             'results': [],
         }
+
+        obj_ids = set([result['id_stored'] for result in results])
+    
         search_results = []
-        for result in results:
-            _log.info(result)
-            obj_id = result['id_stored']
+        for obj_id in obj_ids:
             obj = self.model.query.get(obj_id)
             search_results.append({
                 'slug': obj.slug,
@@ -35,8 +36,10 @@ class MediaEntrySearchIndex(SearchIndex):
             })
         
         all_results['results'] = search_results
+
         _log.info("Found results ")
         _log.info(all_results)
+        
         return all_results
 
 
@@ -59,9 +62,9 @@ class MediaTagSearchIndex(SearchIndex):
             'css_id': self.css_id,
             'results': [],
         }
+        obj_ids = set([result['id_stored'] for result in results])
         search_results = []
-        for result in results:
-            obj_id = result['id_stored']
+        for obj_id in obj_ids:
             obj = self.model.query.get(obj_id)
             media_entry_obj = MediaEntry.query.get(obj.media_entry)
             search_results.append({
-- 
1.8.5.3



More information about the devel mailing list