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'
|
__author__ = 'Aran'
|
||||||
|
|
||||||
from flask import Blueprint
|
from flask import Blueprint
|
||||||
|
@ -245,9 +247,11 @@ def getAllUserMessages(token):
|
||||||
|
|
||||||
arr = []
|
arr = []
|
||||||
|
|
||||||
query = Message.all()
|
allMsgs = Message.all()
|
||||||
query.filter('isProject =', False)
|
projectMsgs = copy.deepcopy(allMsgs)
|
||||||
for m in query.run():
|
|
||||||
|
projectMsgs.filter('isProject =', False)
|
||||||
|
for m in projectMsgs.run():
|
||||||
if str(m.groupId) in user.courses_id_list:
|
if str(m.groupId) in user.courses_id_list:
|
||||||
msgDic = dict(json.loads(m.to_JSON()))
|
msgDic = dict(json.loads(m.to_JSON()))
|
||||||
#add a key 'forSortDate' for sorting dates
|
#add a key 'forSortDate' for sorting dates
|
||||||
|
@ -255,9 +259,9 @@ def getAllUserMessages(token):
|
||||||
msgDic['forSortDate'] = msgTime
|
msgDic['forSortDate'] = msgTime
|
||||||
arr.append(msgDic)
|
arr.append(msgDic)
|
||||||
|
|
||||||
query = Message.all()
|
|
||||||
query.filter('isProject =', True)
|
allMsgs.filter('isProject =', True)
|
||||||
for m in query.run():
|
for m in allMsgs.run():
|
||||||
if str(m.groupId) in user.projects_id_list:
|
if str(m.groupId) in user.projects_id_list:
|
||||||
msgDic = dict(json.loads(m.to_JSON()))
|
msgDic = dict(json.loads(m.to_JSON()))
|
||||||
#add a key 'forSortDate' for sorting dates
|
#add a key 'forSortDate' for sorting dates
|
||||||
|
|
Loading…
Reference in a new issue