main
Ernest Litvinenko 2024-07-10 19:09:37 +03:00
parent 9d01a17453
commit cfa8c1b854
3 changed files with 18 additions and 6 deletions

View File

@ -45,7 +45,8 @@ class MarshTemperaturePropertyQL(Enum):
class Query:
@strawberry.field
def tasks(self, user_id: str, is_planned: typing.Optional[bool] = False, is_completed: typing.Optional[bool] = False) -> list['AppTaskQL']:
def tasks(self, user_id: str, is_planned: typing.Optional[bool] = False,
is_completed: typing.Optional[bool] = False) -> list['AppTaskQL']:
tasks = task_storage.fetch_tasks_with_subtasks(user_id)
if is_planned:
@ -72,6 +73,15 @@ class Query:
except StopIteration:
return None
@strawberry.field
def count_planned_tasks(self, user_id: str) -> int:
return len(
[x for x in task_storage.fetch_tasks_with_subtasks(int(user_id)) if x.status == x.status.NOT_DEFINED])
@strawberry.field
def count_completed_tasks(self, user_id: str) -> int:
return len([x for x in task_storage.fetch_tasks_with_subtasks(int(user_id)) if x.status == x.status.COMPLETED])
@strawberry.field
def notes(self, user_id: str) -> list['AppNoteQL']:
return note_storage.fetch_all_notes_for_user(int(user_id))
@ -84,6 +94,10 @@ class Query:
except StopIteration:
return None
@strawberry.field
def subtasks(self, user_id: str) -> list['SubtaskQL']:
return [s for t in task_storage.fetch_tasks_with_subtasks(int(user_id)) for s in t.subtasks]
@strawberry.experimental.pydantic.type(model=Location)
class LocationQL:
@ -105,7 +119,7 @@ class SubtaskQL:
start_fact: strawberry.auto
end_fact: strawberry.auto
status: StatusEnumQl
task_type: int
task_type: str
text: str
station: typing.Optional[MSTQL] = None
@ -151,7 +165,7 @@ class AppTaskQL:
start_fact: strawberry.auto
end_fact: strawberry.auto
status: StatusEnumQl
task_type: int
task_type: str
text: strawberry.auto
events: list[AppEventQL]

View File

@ -29,6 +29,7 @@ async def get_tasks(user: ProfileDB = Depends(get_user_from_token)) -> list[DBAp
@router.post("")
async def upd_task(req: UpdTaskRequest, user: ProfileDB = Depends(get_user_from_token)) -> list[DBAppTask]:
print(req)
def check_task_in_progress(e: UpdTaskData, t: DBAppTask):
t.subtasks.sort(key=lambda u: u.start_pln)
try:

View File

@ -1,7 +1,4 @@
from importlib import reload
from fastapi import FastAPI, Request
from fastapi.responses import JSONResponse
from fastapi.exceptions import RequestValidationError
from core.transport.rest import router