summaryrefslogtreecommitdiffstats
path: root/lib/mongo.py
diff options
context:
space:
mode:
authorPierre-Yves Chibon <pingou@pingoured.fr>2012-03-18 14:37:11 +0100
committerPierre-Yves Chibon <pingou@pingoured.fr>2012-03-18 14:37:11 +0100
commitd6b016f194f0a768efc4cd435a634fdaeb0c148b (patch)
tree7d9b2afe55aecea480ec451994cae31a15c89a5d /lib/mongo.py
parent5b7388305a945ed42ce08495e81610b904253fa3 (diff)
downloadhyperkitty-d6b016f194f0a768efc4cd435a634fdaeb0c148b.tar.gz
hyperkitty-d6b016f194f0a768efc4cd435a634fdaeb0c148b.tar.xz
hyperkitty-d6b016f194f0a768efc4cd435a634fdaeb0c148b.zip
Fix the aggregation of the thread -- Use References instead of In-Reply-To
Diffstat (limited to 'lib/mongo.py')
-rw-r--r--lib/mongo.py12
1 files changed, 7 insertions, 5 deletions
diff --git a/lib/mongo.py b/lib/mongo.py
index 55f4129..e429eea 100644
--- a/lib/mongo.py
+++ b/lib/mongo.py
@@ -1,6 +1,7 @@
#-*- coding: utf-8 -*-
import pymongo
+import re
from bunch import Bunch
connection = pymongo.Connection('localhost', 27017)
@@ -13,7 +14,8 @@ def get_emails_thread(table, start_email, thread):
db.mails.ensure_index('In-Reply-To')
db.mails.create_index('Message-ID')
db.mails.ensure_index('Message-ID')
- for el in db.mails.find({'In-Reply-To': start_email['Message-ID']},
+ regex = '.*%s.*' % start_email['Message-ID']
+ for el in db.mails.find({'References': re.compile(regex, re.IGNORECASE)},
sort=[('Date', pymongo.DESCENDING)]):
thread.append(el)
get_emails_thread(el, thread)
@@ -24,11 +26,11 @@ def get_archives(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 = []
- 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)]):
archives.append(el)