from fastapi import Depends
from sqlmodel import select

from joj.horse import models, schemas
from joj.horse.schemas import StandardListResponse
from joj.horse.schemas.auth import Authentication
from joj.horse.utils.parser import parse_ordering_query, parse_pagination_query
from joj.horse.utils.router import MyRouter

router = MyRouter()
router_name = "problem_groups"
router_tag = "problem group"
router_prefix = "/api/v1"


@router.get("")
async def list_problem_groups(
    ordering: schemas.OrderingQuery = Depends(parse_ordering_query()),
    pagination: schemas.PaginationQuery = Depends(parse_pagination_query),
    auth: Authentication = Depends(),
) -> StandardListResponse[schemas.ProblemGroup]:
    statement = select(models.ProblemGroup)
    problem_groups, count = await models.ProblemGroup.execute_list_statement(
        statement, ordering, pagination
    )
    return StandardListResponse(problem_groups, count)

joj.horse.utils.router.MyRouter joj.horse.utils.parser.parse_ordering_query joj.horse.schemas.StandardListResponse joj.horse.models.ProblemGroup.execute_list_statement sqlmodel.select fastapi.Depends
[((330, 340), 'joj.horse.utils.router.MyRouter', 'MyRouter', ([], {}), '()\n', (338, 340), False, 'from joj.horse.utils.router import MyRouter\n'), ((589, 620), 'fastapi.Depends', 'Depends', (['parse_pagination_query'], {}), '(parse_pagination_query)\n', (596, 620), False, 'from fastapi import Depends\n'), ((649, 658), 'fastapi.Depends', 'Depends', ([], {}), '()\n', (656, 658), False, 'from fastapi import Depends\n'), ((725, 752), 'sqlmodel.select', 'select', (['models.ProblemGroup'], {}), '(models.ProblemGroup)\n', (731, 752), False, 'from sqlmodel import select\n'), ((888, 931), 'joj.horse.schemas.StandardListResponse', 'StandardListResponse', (['problem_groups', 'count'], {}), '(problem_groups, count)\n', (908, 931), False, 'from joj.horse.schemas import StandardListResponse\n'), ((522, 544), 'joj.horse.utils.parser.parse_ordering_query', 'parse_ordering_query', ([], {}), '()\n', (542, 544), False, 'from joj.horse.utils.parser import parse_ordering_query, parse_pagination_query\n'), ((787, 862), 'joj.horse.models.ProblemGroup.execute_list_statement', 'models.ProblemGroup.execute_list_statement', (['statement', 'ordering', 'pagination'], {}), '(statement, ordering, pagination)\n', (829, 862), False, 'from joj.horse import models, schemas\n')]