GPQBot
1"""Task repo."""
2
3from typing import List
4from uuid import UUID
5
6from app.db.crud import CRUD
7from app.db.sqlalchemy import AsyncSession
8from app.db.task.models import Fidback
9from app.schemas.shemas import Fidback, FidbackCreate
10
11
12class TaskRepo:
13def __init__(self, session: AsyncSession):
14self._crud = CRUD(session=session, cls_model=Fidback)
15
16async def create_task(self, task_in_creation: FidbackCreate) -> Fidback:
17model_data = {
18"division": task_in_creation.title,
19"subdivision": task_in_creation.title,
20"description": task_in_creation.description,
21}
22row = await self._crud.create(model_data=model_data)
23
24task_in_db = await self._crud.get(pkey_val=row.id)
25
26return self._to_domain(task_in_db)
27
28async def get_task(self, task_id: int) -> Fidback:
29task_in_db = await self._crud.get(pkey_val=task_id)
30return self._to_domain(task_in_db)
31
32async def delete_task(self, task_id: int) -> None:
33await self._crud.delete(pkey_val=task_id)
34