Sort list of users and projects returned from queries

Change-Id: Ic41d303d332ccb47907450027f5a09a825cc522f
Signed-off-by: Doug Hellmann <doug.hellmann@dreamhost.com>
This commit is contained in:
Doug Hellmann 2012-08-06 16:44:17 -04:00
parent fd6348d363
commit fc2cb21771

View File

@ -253,24 +253,20 @@ class Connection(base.Connection):
:param source: Optional source filter.
"""
q = {}
if source is not None:
q = {'source': source,
}
return self.db.user.find(q).distinct('_id')
else:
return self.db.user.distinct('_id')
q['source'] = source
return sorted(self.db.user.find(q).distinct('_id'))
def get_projects(self, source=None):
"""Return an iterable of project id strings.
:param source: Optional source filter.
"""
q = {}
if source is not None:
q = {'source': source,
}
return self.db.project.find(q).distinct('_id')
else:
return self.db.project.distinct('_id')
q['source'] = source
return sorted(self.db.project.find(q).distinct('_id'))
def get_resources(self, user=None, project=None, source=None):
"""Return an iterable of dictionaries containing resource information.