changeset 762:25e07ced506f

backrefs using whoosh now Fixes #23.
author Michael Mayorov <marchael@kb.csu.ru>
date Sun, 21 Aug 2011 23:27:21 +0000
parents 2151ef2c8425
children f06e9d502d6c
files MoinMoin/apps/frontend/views.py
diffstat 1 files changed, 8 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/apps/frontend/views.py	Fri Aug 19 14:12:47 2011 +0000
+++ b/MoinMoin/apps/frontend/views.py	Sun Aug 21 23:27:21 2011 +0000
@@ -573,21 +573,14 @@
     :type item_name: unicode
     :returns: the list of all items which ref item_name
     """
-    refs_here = []
-    for item in items:
-        current_item = item.name
-        try:
-            current_revision = item.get_revision(-1)
-        except NoSuchRevisionError:
-            continue
-        links = current_revision.get(ITEMLINKS, [])
-        transclusions = current_revision.get(ITEMTRANSCLUSIONS, [])
-
-        refs = set(links + transclusions)
-        if item_name in refs:
-            refs_here.append(current_item)
-    return refs_here
-
+    from MoinMoin.search.indexing import WhooshIndex
+    from whoosh.query import Term, Or
+    index_object = WhooshIndex()
+    ix = index_object.latest_revisions_index
+    with ix.searcher() as searcher:
+        q = Or([Term("itemtransclusions", item_name), Term("itemlinks", item_name)])
+        results = searcher.search(q)
+        return [result["name"] for result in results]
 
 @frontend.route('/+history/<itemname:item_name>')
 def history(item_name):