allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brond...@apache.org
Subject [08/38] git commit: [#4019] ticket:481 Filter search
Date Wed, 30 Apr 2014 18:15:40 GMT
[#4019] ticket:481 Filter search


Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/bd7767db
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/bd7767db
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/bd7767db

Branch: refs/heads/master
Commit: bd7767db234201042b739126fa110c3a0d5b35b4
Parents: 6fd2932
Author: Igor Bondarenko <jetmind2@gmail.com>
Authored: Tue Dec 17 17:06:20 2013 +0200
Committer: Dave Brondsema <dbrondsema@slashdotmedia.com>
Committed: Wed Apr 30 15:55:09 2014 +0000

----------------------------------------------------------------------
 Allura/allura/lib/search.py               | 7 +++++--
 ForgeTracker/forgetracker/model/ticket.py | 3 ++-
 2 files changed, 7 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/bd7767db/Allura/allura/lib/search.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/search.py b/Allura/allura/lib/search.py
index 419a473..1ce7cd9 100644
--- a/Allura/allura/lib/search.py
+++ b/Allura/allura/lib/search.py
@@ -78,7 +78,7 @@ def search(q, short_timeout=False, ignore_errors=True, **kw):
                               (match.group(1) if match else e))
 
 
-def search_artifact(atype, q, history=False, rows=10, short_timeout=False, **kw):
+def search_artifact(atype, q, history=False, rows=10, short_timeout=False, filter=None, **kw):
     """Performs SOLR search.
 
     Raises SearchError if SOLR returns an error.
@@ -93,7 +93,10 @@ def search_artifact(atype, q, history=False, rows=10, short_timeout=False,
**kw)
     fq = [
         'type_s:%s' % fields['type_s'],
         'project_id_s:%s' % c.project._id,
-        'mount_point_s:%s' % c.app.config.options.mount_point]
+        'mount_point_s:%s' % c.app.config.options.mount_point ]
+    for name, values in (filter or {}).iteritems():
+        field_name = name + '_s' if name != '_milestone' else 'milestone_s'
+        fq.append(' OR '.join('%s:%s' % (field_name, v) for v in values))
     if not history:
         fq.append('is_history_b:False')
     return search(q, fq=fq, rows=rows, short_timeout=short_timeout, ignore_errors=False,
**kw)

http://git-wip-us.apache.org/repos/asf/allura/blob/bd7767db/ForgeTracker/forgetracker/model/ticket.py
----------------------------------------------------------------------
diff --git a/ForgeTracker/forgetracker/model/ticket.py b/ForgeTracker/forgetracker/model/ticket.py
index 5ad9f3a..72cc23a 100644
--- a/ForgeTracker/forgetracker/model/ticket.py
+++ b/ForgeTracker/forgetracker/model/ticket.py
@@ -1156,7 +1156,8 @@ class Ticket(VersionedArtifact, ActivityObject, VotableArtifact):
             if q:
                 matches = search_artifact(
                     cls, q, short_timeout=True,
-                    rows=limit, sort=refined_sort, start=start, fl='ticket_num_i', **kw)
+                    rows=limit, sort=refined_sort, start=start, fl='ticket_num_i',
+                    filter=filter, **kw)
             else:
                 matches = None
             solr_error = None


Mime
View raw message