changeset 4832:319b16518227

db: check for None instead of boolean false if that is what we mean If matters a lot whether we find all comments for the specified empty list of changesets or for None meaning the whole repository.
author Mads Kiilerich <madski@unity3d.com>
date Wed, 11 Feb 2015 03:05:00 +0100
parents 73effddded57
children 9488ba27f754
files kallithea/model/db.py
diffstat 1 files changed, 4 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/kallithea/model/db.py	Wed Feb 11 02:40:28 2015 +0100
+++ b/kallithea/model/db.py	Wed Feb 11 03:05:00 2015 +0100
@@ -1222,7 +1222,7 @@
 
     @classmethod
     def lock(cls, repo, user_id, lock_time=None):
-        if not lock_time:
+        if lock_time is not None:
             lock_time = time.time()
         repo.locked = [user_id, lock_time]
         Session().add(repo)
@@ -1358,7 +1358,7 @@
         """
         cmts = ChangesetComment.query()\
             .filter(ChangesetComment.repo == self)
-        if revisions:
+        if revisions is not None:
             cmts = cmts.filter(ChangesetComment.revision.in_(revisions))
         grouped = collections.defaultdict(list)
         for cmt in cmts.all():
@@ -2172,9 +2172,9 @@
         """
         q = Session().query(User)\
                 .join(ChangesetComment.author)
-        if revision:
+        if revision is not None:
             q = q.filter(cls.revision == revision)
-        elif pull_request_id:
+        elif pull_request_id is not None:
             q = q.filter(cls.pull_request_id == pull_request_id)
         return q.all()