Work on count nb task (and nb note)

This commit is contained in:
2018-07-04 02:30:40 +02:00
parent 17d42cc584
commit 7726f53013
2 changed files with 19 additions and 6 deletions

View File

@@ -21,7 +21,7 @@ def handle_project(args, last_action, conn):
if args.delete_id:
do_something = True
delete_project(args.delete_id, conn)
if args.edit_id:
do_something = True
edit_project(args, args.edit_id, conn)
@@ -94,13 +94,16 @@ def delete_project(project_id, conn):
def list_project(active_project_id, conn):
logging.info('>> No arguments')
query = "SELECT id, username, name, status, created_at FROM project;"
query = """
SELECT id, username, name, status, created_at,
(SELECT count(*) FROM task WHERE task.project_id = project.id)
FROM project;
"""
cursor = conn.cursor()
cursor.execute(query)
for row in cursor.fetchall():
project_id, username, name, status, date = row
nb_task = 0
project_id, username, name, status, date, nb_task = row
current_project = ''
if active_project_id and active_project_id == project_id: current_project = '*'
print('{:1} {:2d}: ({:8}) | {} | {} ({} tasks )'.format(current_project, project_id, username, status, name, nb_task))
print('{:1} {:2d}: ({:8}) | {} | {} ({} tasks)'.format(current_project, project_id, username, status, name, nb_task))