Bugfix: Exclude expired claimed messages in stats.

Change-Id: I6dcec40b967c29c8c291c8251b61949c7e672e26
This commit is contained in:
Zhihao Yuan 2013-04-16 17:09:31 -04:00
parent efcb1111af
commit 0f77d41a96

View File

@ -189,13 +189,12 @@ class MessageController(storage.MessageBase):
query = {
"c.id": claim_id,
"c.e": {"$gt": expires or timeutils.utcnow_ts()},
"q": utils.to_oid(queue),
}
if not claim_id:
# lookup over c.id to use the index
query["c.id"] = {"$ne": None}
if expires:
query["c.e"] = {"$gt": expires}
msgs = self._col.find(query, sort=[("_id", 1)])