copying an object instead of re-requesting from db
This commit is contained in:
parent
0c6af92021
commit
55593a6542
1 changed files with 10 additions and 6 deletions
|
@ -1,3 +1,5 @@
|
|||
import copy
|
||||
|
||||
__author__ = 'Aran'
|
||||
|
||||
from flask import Blueprint
|
||||
|
@ -245,9 +247,11 @@ def getAllUserMessages(token):
|
|||
|
||||
arr = []
|
||||
|
||||
query = Message.all()
|
||||
query.filter('isProject =', False)
|
||||
for m in query.run():
|
||||
allMsgs = Message.all()
|
||||
projectMsgs = copy.deepcopy(allMsgs)
|
||||
|
||||
projectMsgs.filter('isProject =', False)
|
||||
for m in projectMsgs.run():
|
||||
if str(m.groupId) in user.courses_id_list:
|
||||
msgDic = dict(json.loads(m.to_JSON()))
|
||||
#add a key 'forSortDate' for sorting dates
|
||||
|
@ -255,9 +259,9 @@ def getAllUserMessages(token):
|
|||
msgDic['forSortDate'] = msgTime
|
||||
arr.append(msgDic)
|
||||
|
||||
query = Message.all()
|
||||
query.filter('isProject =', True)
|
||||
for m in query.run():
|
||||
|
||||
allMsgs.filter('isProject =', True)
|
||||
for m in allMsgs.run():
|
||||
if str(m.groupId) in user.projects_id_list:
|
||||
msgDic = dict(json.loads(m.to_JSON()))
|
||||
#add a key 'forSortDate' for sorting dates
|
||||
|
|
Loading…
Reference in a new issue