summaryrefslogtreecommitdiff
path: root/service/pixelated
diff options
context:
space:
mode:
authorPatrick Maia <patrickjourdanmaia@gmail.com>2014-12-12 18:04:56 +0000
committerPatrick Maia <patrickjourdanmaia@gmail.com>2014-12-12 18:04:56 +0000
commit0d702851a2cfca3db85fd63a3b6093797f2aafb8 (patch)
treefe0228f91d1970ab093e604a3a37014cd39b8936 /service/pixelated
parenta0bc490dc985f88d8a7f9a835e6cd202e82cc760 (diff)
Card #168 - ignores contacts coming from trash and drafts
Diffstat (limited to 'service/pixelated')
-rw-r--r--service/pixelated/adapter/search.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/service/pixelated/adapter/search.py b/service/pixelated/adapter/search.py
index 703f2f51..d1e43735 100644
--- a/service/pixelated/adapter/search.py
+++ b/service/pixelated/adapter/search.py
@@ -22,6 +22,7 @@ from pixelated.support.functional import flatten
from whoosh.index import FileIndex
from whoosh.fields import *
from whoosh.qparser import QueryParser
+from whoosh.query import Term
from whoosh import sorting
from pixelated.support.functional import unique
from pixelated.support.date import milliseconds
@@ -184,16 +185,18 @@ class SearchEngine(object):
writer.commit()
def contacts(self, query):
+ restrict_q = Term("tag", "drafts") | Term("tag", "trash")
+
if query:
to = QueryParser('to', self._index.schema)
cc = QueryParser('cc', self._index.schema)
bcc = QueryParser('bcc', self._index.schema)
with self._index.searcher() as searcher:
- to = searcher.search(to.parse("*%s*" % query), limit=None,
+ to = searcher.search(to.parse("*%s*" % query), limit=None, mask=restrict_q,
groupedby=sorting.FieldFacet('to', allow_overlap=True)).groups()
- cc = searcher.search(cc.parse("*%s*" % query), limit=None,
+ cc = searcher.search(cc.parse("*%s*" % query), limit=None, mask=restrict_q,
groupedby=sorting.FieldFacet('cc', allow_overlap=True)).groups()
- bcc = searcher.search(bcc.parse("*%s*" % query), limit=None,
+ bcc = searcher.search(bcc.parse("*%s*" % query), limit=None, mask=restrict_q,
groupedby=sorting.FieldFacet('bcc', allow_overlap=True)).groups()
return flatten([to, cc, bcc])