From 491f6aba082f9beb8263d270be326e9c88de2c06 Mon Sep 17 00:00:00 2001 From: aranzaiger Date: Mon, 3 Aug 2015 01:48:28 +0300 Subject: [PATCH] fix devision by zero --- SE_API/MessageRoutes.py | 4 ++-- SE_API/TaskRoutes.py | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/SE_API/MessageRoutes.py b/SE_API/MessageRoutes.py index 486a1f3..31d7d4f 100644 --- a/SE_API/MessageRoutes.py +++ b/SE_API/MessageRoutes.py @@ -176,7 +176,7 @@ def getMessagesByGroup(token, groupId): msgDic['forSortDate'] = msgTime arr.append(msgDic) print arr - arr = sorted(arr, key=itemgetter('forSortDate'), reverse=False) + arr = sorted(arr, key=itemgetter('forSortDate'), reverse=True) for i in arr: del i['forSortDate'] print arr @@ -270,7 +270,7 @@ def getAllUserMessages(token): msgDic['forSortDate'] = msgTime arr.append(msgDic) - arr = sorted(arr, key=itemgetter('forSortDate'), reverse=False) + arr = sorted(arr, key=itemgetter('forSortDate'), reverse=True) for i in arr: del i['forSortDate'] print arr diff --git a/SE_API/TaskRoutes.py b/SE_API/TaskRoutes.py index 72dcff5..efc95cb 100644 --- a/SE_API/TaskRoutes.py +++ b/SE_API/TaskRoutes.py @@ -726,7 +726,10 @@ def getAllUserTasks(token): basicTC = TaskComponent.all().filter("taskId = ", t.key().id()).filter("userId = ", -1).count() allTC = TaskComponent.all().filter("taskId = ", t.key().id()).count() - done = (allTC/basicTC) - 1 + if basicTC != 0: + done = (allTC/basicTC) - 1 + else: + done = 0 taskDic['submitted']['done'] = done taskArr.append(taskDic)