mirror of
https://framagit.org/framasoft/framaspace/argos.git
synced 2025-04-28 18:02:41 +02:00
🎨 — Modify count_tasks behavior, improve its signature
This commit is contained in:
parent
7bfe676b5c
commit
be492ed2ee
2 changed files with 8 additions and 7 deletions
|
@ -51,7 +51,7 @@ def create_start_app_handler(appli):
|
|||
|
||||
db = await connect_to_db(appli)
|
||||
|
||||
tasks_count = await queries.count_tasks(db, all_tasks=True)
|
||||
tasks_count = await queries.count_tasks(db)
|
||||
if tasks_count == 0:
|
||||
logger.warning(
|
||||
"There is no tasks in the database. "
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
"""Functions to ease SQL queries management"""
|
||||
from datetime import datetime, timedelta
|
||||
from hashlib import sha256
|
||||
from typing import List
|
||||
from typing import List, Union
|
||||
from urllib.parse import urljoin
|
||||
|
||||
from sqlalchemy import desc, func
|
||||
|
@ -48,11 +48,12 @@ async def create_result(db: Session, agent_result: schemas.AgentResult, agent_id
|
|||
return result
|
||||
|
||||
|
||||
async def count_tasks(db: Session, selected=False, all_tasks=False):
|
||||
async def count_tasks(db: Session, selected: Union[None, bool] = None):
|
||||
query = db.query(Task)
|
||||
if selected is not None:
|
||||
if selected:
|
||||
query = query.filter(Task.selected_by is not None)
|
||||
elif not all_tasks:
|
||||
else:
|
||||
query = query.filter(Task.selected_by is None)
|
||||
|
||||
return query.count()
|
||||
|
|
Loading…
Reference in a new issue