Skip to content

Commit

Permalink
[qa] black
Browse files Browse the repository at this point in the history
  • Loading branch information
EvanBldy committed Aug 28, 2024
1 parent 38646c0 commit 19b6b8c
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 22 deletions.
9 changes: 3 additions & 6 deletions zou/app/blueprints/crud/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,16 +66,13 @@ def apply_filters(self, query, options):
if episode_id is not None:
Sequence = aliased(Entity)
query = (
query
.join(Entity, Task.entity_id == Entity.id)
query.join(Entity, Task.entity_id == Entity.id)
.join(Sequence, Entity.parent_id == Sequence.id)
.filter(Sequence.parent_id == episode_id)
)
elif project_id is not None:
query = (
query
.join(Entity, Task.entity_id == Entity.id)
.filter(Entity.project_id == project_id)
query = query.join(Entity, Task.entity_id == Entity.id).filter(
Entity.project_id == project_id
)

return query
Expand Down
5 changes: 1 addition & 4 deletions zou/app/blueprints/tasks/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -1503,10 +1503,7 @@ def get(self, project_id):
task_type_id = self.get_task_type_id()
episode_id = self.get_episode_id()
return tasks_service.get_tasks_for_project(
project_id,
page,
task_type_id=task_type_id,
episode_id=episode_id
project_id, page, task_type_id=task_type_id, episode_id=episode_id
)


Expand Down
9 changes: 2 additions & 7 deletions zou/app/services/tasks_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -1699,10 +1699,7 @@ def get_time_spents_for_project(project_id, page=0):


def get_tasks_for_project(
project_id,
page=0,
task_type_id=None,
episode_id=None
project_id, page=0, task_type_id=None, episode_id=None
):
"""
Return all tasks for given project.
Expand All @@ -1715,8 +1712,7 @@ def get_tasks_for_project(
if episode_id is not None:
Sequence = aliased(Entity, name="sequence")
query = (
query
.join(Entity, Entity.id == Task.entity_id)
query.join(Entity, Entity.id == Task.entity_id)
.join(Sequence, Sequence.id == Entity.parent_id)
.filter(Sequence.parent_id == episode_id)
)
Expand All @@ -1729,7 +1725,6 @@ def get_tasks_for_project(
)
return query


return query_utils.get_paginated_results(query, page, relations=True)


Expand Down
5 changes: 3 additions & 2 deletions zou/app/utils/dbhelpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ def is_init():
"""
from zou.app import db
from zou.app.models.project_status import ProjectStatus

return (
inspect(db.engine).has_table("person")
and db.session.query(ProjectStatus).count() == 2
inspect(db.engine).has_table("person")
and db.session.query(ProjectStatus).count() == 2
)
8 changes: 5 additions & 3 deletions zou/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,18 @@ def init_db():
@cli.command()
def is_db_ready():
"""
Return a message telling if the database wheter the database is
Return a message telling if the database wheter the database is
initiliazed or not."
"""
with app.app_context():
is_init = dbhelpers.is_init()
if is_init:
print("Database is initiliazed.")
else:
print("Database is not initiliazed. "
"Run 'zou init-db' and 'init-data'.")
print(
"Database is not initiliazed. "
"Run 'zou init-db' and 'init-data'."
)


@cli.command()
Expand Down

0 comments on commit 19b6b8c

Please sign in to comment.