Skip to content

Commit

Permalink
Merge pull request hotosm#3208 from hotosm/fix/loops-compressed-in-tasks
Browse files Browse the repository at this point in the history
loop compressed and array initialized
  • Loading branch information
ramyaragupathy authored Jun 26, 2020
2 parents 435afd8 + bab422e commit c2cdd8a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
5 changes: 5 additions & 0 deletions backend/models/dtos/project_dto.py
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,11 @@ def __init__(self):
class LockedTasksForUser(Model):
""" Describes all tasks locked by an individual user"""

def __init__(self):
""" DTO constructor initialise all arrays to empty"""
super().__init__()
self.locked_tasks = []

locked_tasks = ListType(IntType, serialized_name="lockedTasks")
project = IntType(serialized_name="projectId")
task_status = StringType(serialized_name="taskStatus")
Expand Down
9 changes: 2 additions & 7 deletions backend/models/postgis/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -851,8 +851,7 @@ def get_tasks_as_geojson_feature_collection(
if not tasks or len(tasks) == 0:
raise NotFound()
else:
for task in tasks:
tasks_filters.append(task.id)
tasks_filters = [task.id for task in tasks]
filters = [Task.project_id == project_id, Task.id.in_(tasks_filters)]
else:
tasks = Task.get_all_tasks(project_id)
Expand Down Expand Up @@ -1105,7 +1104,6 @@ def get_locked_tasks_for_user(user_id: int):
""" Gets tasks on project owned by specified user id"""
tasks = Task.query.filter_by(locked_by=user_id)
tasks_dto = LockedTasksForUser()
tasks_dto.locked_tasks = []
for task in tasks:
tasks_dto.locked_tasks.append(task.id)
tasks_dto.project = task.project_id
Expand All @@ -1116,9 +1114,6 @@ def get_locked_tasks_for_user(user_id: int):
def get_locked_tasks_details_for_user(user_id: int):
""" Gets tasks on project owned by specified user id"""
tasks = Task.query.filter_by(locked_by=user_id)

locked_tasks = []
for task in tasks:
locked_tasks.append(task)
locked_tasks = [task for task in tasks]

return locked_tasks

0 comments on commit c2cdd8a

Please sign in to comment.