diff options
author | Milo Casagrande <milo.casagrande@linaro.org> | 2015-01-20 15:21:50 +0100 |
---|---|---|
committer | Milo Casagrande <milo.casagrande@linaro.org> | 2015-01-20 15:21:50 +0100 |
commit | 633a35ef7a4096ae395fee98c16bf130b558336f (patch) | |
tree | 4e27dc4673ffed089f1e67b29fa84753beaac3d4 | |
parent | 50d26e3567cb1ff96187e9feb80476646ac5af31 (diff) |
Fix argument orders and checks.
Change-Id: I9a8603fd36b3fda3b45220ee8c0a91814cbd3aab
-rw-r--r-- | app/handlers/base.py | 2 | ||||
-rw-r--r-- | app/utils/db.py | 10 |
2 files changed, 6 insertions, 6 deletions
diff --git a/app/handlers/base.py b/app/handlers/base.py index a0d0f64..228150c 100644 --- a/app/handlers/base.py +++ b/app/handlers/base.py @@ -435,9 +435,9 @@ class BaseHandler(tornado.web.RequestHandler): response.result = utils.db.aggregate( self.collection, unique, + match=spec, sort=sort, fields=fields, - match=spec, limit=limit ) else: diff --git a/app/utils/db.py b/app/utils/db.py index f1f51f9..3885a68 100644 --- a/app/utils/db.py +++ b/app/utils/db.py @@ -363,14 +363,14 @@ def aggregate( # Where the aggregate actions and values will be stored. pipeline = [] - if match: + if match is not None: pipeline.append({ "$match": match }) # XXX: For strange reasons, sort needs to happen before, and also # after grouping, or the resulsts are completely random - if sort: + if sort is not None: pipeline.append({ "$sort": { k: v for k, v in sort @@ -383,7 +383,7 @@ def aggregate( } } - if fields: + if fields is not None: fields = [ (k, v) for k, v in [ (key, val) @@ -399,7 +399,7 @@ def aggregate( # XXX: For strange reasons, sort needs to happen before, and also # after grouping, or the resulsts are completely random - if sort: + if sort is not None: pipeline.append({ "$sort": { k: v for k, v in sort @@ -407,7 +407,7 @@ def aggregate( }) # Make sure we return the exact number of elements after grouping them. - if limit: + if all([limit is not None, limit > 0]): pipeline.append({ "$limit": limit }) |