Commit 41181b44 authored by Vũ Hoàng Anh's avatar Vũ Hoàng Anh

fix(api): change list_company_skills to return flat List[CompanySkillResponse]...

fix(api): change list_company_skills to return flat List[CompanySkillResponse] to fix frontend crash
parent 39f23bcb
......@@ -2,7 +2,7 @@
Company skill routes.
"""
from typing import Optional
from typing import Optional, List
from fastapi import APIRouter, Depends, HTTPException, Query, status
from sqlalchemy.ext.asyncio import AsyncSession
from sqlalchemy import select, func
......@@ -60,7 +60,7 @@ async def create_company_skill(
return db_skill
@router.get("", response_model=PaginatedResponse)
@router.get("", response_model=List[CompanySkillResponse])
async def list_company_skills(
company_id: str = Query(..., description="Company ID"),
scope: CompanyScope = Depends(require_company_scope),
......@@ -76,17 +76,11 @@ async def list_company_skills(
rows = result.fetchall()
if not rows:
return {"total": 0, "offset": pagination.offset, "limit": pagination.limit, "items": []}
return []
total = rows[0].total
skills = [CompanySkillResponse.model_validate(row._mapping["CompanySkill"]) for row in rows]
return skills
return {
"total": total,
"offset": pagination.offset,
"limit": pagination.limit,
"items": skills,
}
@router.get("/{skill_id}", response_model=CompanySkillResponse)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment