From f3df5c9bc1110dc602ebfbceec4a82aadbe2947e Mon Sep 17 00:00:00 2001 From: Ralph Bean Date: Sat, 3 Aug 2013 00:08:04 -0400 Subject: [PATCH] Correctly deal with counting paginated results from datanommer. --- fedbadges/rules.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/fedbadges/rules.py b/fedbadges/rules.py index 42c2468..4a5e793 100644 --- a/fedbadges/rules.py +++ b/fedbadges/rules.py @@ -366,10 +366,13 @@ def construct_query(self, msg): kwargs = recursive_lambda_factory(kwargs, msg, name='msg') kwargs['defer'] = True total, pages, query = datanommer.models.Message.grep(**kwargs) - return query + return total, pages, query def matches(self, msg): - query = self.construct_query(msg) - operation = getattr(query, self._d['operation']) - result = operation() + total, pages, query = self.construct_query(msg) + if self._d['operation'] == 'count': + result = total + else: + operation = getattr(query, self._d['operation']) + result = operation() return self.condition(result)