summaryrefslogtreecommitdiffstats
path: root/lib/mongo.py
diff options
context:
space:
mode:
authorPierre-Yves Chibon <pingou@pingoured.fr>2012-03-18 14:11:11 +0100
committerPierre-Yves Chibon <pingou@pingoured.fr>2012-03-18 14:11:11 +0100
commit5b7388305a945ed42ce08495e81610b904253fa3 (patch)
treeffba89ef7dcce50abd22821ca9f40d579a901081 /lib/mongo.py
parentd0bf6dcb43d0a74ca8299166a92991c8c535eb58 (diff)
downloadhyperkitty-5b7388305a945ed42ce08495e81610b904253fa3.tar.gz
hyperkitty-5b7388305a945ed42ce08495e81610b904253fa3.tar.xz
hyperkitty-5b7388305a945ed42ce08495e81610b904253fa3.zip
Use References to detect thread rather than In-Reply-To and add function to search the archives
Diffstat (limited to 'lib/mongo.py')
-rw-r--r--lib/mongo.py20
1 files changed, 15 insertions, 5 deletions
diff --git a/lib/mongo.py b/lib/mongo.py
index b466df1..55f4129 100644
--- a/lib/mongo.py
+++ b/lib/mongo.py
@@ -39,11 +39,11 @@ def get_thread(table, start, end):
db = connection[table]
db.mails.create_index('Date')
db.mails.ensure_index('Date')
- db.mails.create_index('In-Reply-To')
- db.mails.ensure_index('In-Reply-To')
- # Beginning of thread == No 'In-Reply-To' header
+ db.mails.create_index('References')
+ db.mails.ensure_index('References')
+ # Beginning of thread == No 'References' header
archives = Bunch()
- for el in db.mails.find({'In-Reply-To': {'$exists':False},
+ for el in db.mails.find({'References': {'$exists':False},
"Date": {"$gte": start, "$lt": end}},
sort=[('Date', pymongo.DESCENDING)]):
thread = get_emails_thread(el, [el])
@@ -82,4 +82,14 @@ def get_archives_length(table):
for key in archives:
archives[key] = list(archives[key])
return archives
-
+
+
+def search_archives(table, query):
+ db = connection[table]
+ db.mails.create_index('Date')
+ db.mails.ensure_index('Date')
+ for el in query:
+ db.mails.create_index(str(el))
+ db.mails.ensure_index(str(el))
+ return db.mails.find(query,
+ sort=[('Date', pymongo.DESCENDING)]).limit(50)