fix: _to_message_out → message_out, _to_step_out → step_out, убраны сломанные алиасы
Some checks failed
Deploy Tracker / deploy (push) Failing after 3s
Some checks failed
Deploy Tracker / deploy (push) Failing after 3s
This commit is contained in:
parent
d0c0c87120
commit
659454c2e6
@ -124,7 +124,7 @@ async def create_message(req: MessageCreate, request: Request, db: AsyncSession
|
|||||||
author_slug = msg.author.slug if msg.author else "system"
|
author_slug = msg.author.slug if msg.author else "system"
|
||||||
|
|
||||||
# Build response using shared converter
|
# Build response using shared converter
|
||||||
msg_data = _to_message_out(msg).model_dump()
|
msg_data = message_out(msg).model_dump()
|
||||||
|
|
||||||
# Broadcast via WebSocket
|
# Broadcast via WebSocket
|
||||||
from tracker.ws.manager import manager
|
from tracker.ws.manager import manager
|
||||||
@ -140,7 +140,7 @@ async def create_message(req: MessageCreate, request: Request, db: AsyncSession
|
|||||||
{"type": "message.new", "data": msg_data},
|
{"type": "message.new", "data": msg_data},
|
||||||
exclude_slug=author_slug,
|
exclude_slug=author_slug,
|
||||||
)
|
)
|
||||||
return _to_message_out(msg)
|
return message_out(msg)
|
||||||
|
|
||||||
if project_id:
|
if project_id:
|
||||||
await manager.broadcast_message(project_id, msg_data, author_slug=author_slug)
|
await manager.broadcast_message(project_id, msg_data, author_slug=author_slug)
|
||||||
@ -150,7 +150,7 @@ async def create_message(req: MessageCreate, request: Request, db: AsyncSession
|
|||||||
exclude_slug=author_slug,
|
exclude_slug=author_slug,
|
||||||
)
|
)
|
||||||
|
|
||||||
return _to_message_out(msg)
|
return message_out(msg)
|
||||||
|
|
||||||
|
|
||||||
@router.get("/messages/{message_id}/replies", response_model=list[MessageOut])
|
@router.get("/messages/{message_id}/replies", response_model=list[MessageOut])
|
||||||
@ -162,4 +162,4 @@ async def list_replies(message_id: str, db: AsyncSession = Depends(get_db)):
|
|||||||
.options(selectinload(Message.attachments), selectinload(Message.author))
|
.options(selectinload(Message.attachments), selectinload(Message.author))
|
||||||
.order_by(Message.created_at)
|
.order_by(Message.created_at)
|
||||||
)
|
)
|
||||||
return [_to_message_out(m) for m in result.scalars()]
|
return [message_out(m) for m in result.scalars()]
|
||||||
|
|||||||
@ -15,8 +15,6 @@ from sqlalchemy.orm import selectinload
|
|||||||
from tracker.database import get_db
|
from tracker.database import get_db
|
||||||
from tracker.models import ProjectFile, Project, Member
|
from tracker.models import ProjectFile, Project, Member
|
||||||
from tracker.api.schemas import ProjectFileOut, MemberBrief
|
from tracker.api.schemas import ProjectFileOut, MemberBrief
|
||||||
from tracker.api.schemas import ProjectFileOut
|
|
||||||
# Using unified schemas from schemas.py
|
|
||||||
|
|
||||||
router = APIRouter(tags=["project-files"])
|
router = APIRouter(tags=["project-files"])
|
||||||
|
|
||||||
@ -42,7 +40,7 @@ def _to_member_brief(member: Member | None) -> MemberBrief | None:
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def _to_project_file_out(f: ProjectFile) -> ProjectFileOut:
|
def project_file_out(f: ProjectFile) -> ProjectFileOut:
|
||||||
"""Convert ProjectFile to ProjectFileOut schema."""
|
"""Convert ProjectFile to ProjectFileOut schema."""
|
||||||
return ProjectFileOut(
|
return ProjectFileOut(
|
||||||
id=str(f.id),
|
id=str(f.id),
|
||||||
@ -88,7 +86,7 @@ async def list_project_files(
|
|||||||
q = q.order_by(ProjectFile.created_at.desc())
|
q = q.order_by(ProjectFile.created_at.desc())
|
||||||
result = await db.execute(q)
|
result = await db.execute(q)
|
||||||
|
|
||||||
return [_to_project_file_out(f) for f in result.scalars().all()]
|
return [project_file_out(f) for f in result.scalars().all()]
|
||||||
|
|
||||||
|
|
||||||
@router.post("/projects/{slug}/files", response_model=ProjectFileOut)
|
@router.post("/projects/{slug}/files", response_model=ProjectFileOut)
|
||||||
@ -145,7 +143,7 @@ async def upload_project_file(
|
|||||||
await db.commit()
|
await db.commit()
|
||||||
await db.refresh(existing_file, ["uploader"])
|
await db.refresh(existing_file, ["uploader"])
|
||||||
|
|
||||||
return _to_project_file_out(existing_file)
|
return project_file_out(existing_file)
|
||||||
else:
|
else:
|
||||||
pf = ProjectFile(
|
pf = ProjectFile(
|
||||||
project_id=project.id,
|
project_id=project.id,
|
||||||
@ -161,7 +159,7 @@ async def upload_project_file(
|
|||||||
await db.commit()
|
await db.commit()
|
||||||
await db.refresh(pf, ["uploader"])
|
await db.refresh(pf, ["uploader"])
|
||||||
|
|
||||||
return _to_project_file_out(pf)
|
return project_file_out(pf)
|
||||||
|
|
||||||
|
|
||||||
@router.get("/projects/{slug}/files/{file_id}")
|
@router.get("/projects/{slug}/files/{file_id}")
|
||||||
@ -183,7 +181,7 @@ async def get_project_file(
|
|||||||
if not pf:
|
if not pf:
|
||||||
raise HTTPException(404, "File not found")
|
raise HTTPException(404, "File not found")
|
||||||
|
|
||||||
return _to_project_file_out(pf)
|
return project_file_out(pf)
|
||||||
|
|
||||||
|
|
||||||
@router.get("/projects/{slug}/files/{file_id}/download")
|
@router.get("/projects/{slug}/files/{file_id}/download")
|
||||||
@ -249,7 +247,7 @@ async def update_project_file(
|
|||||||
await db.commit()
|
await db.commit()
|
||||||
await db.refresh(pf)
|
await db.refresh(pf)
|
||||||
|
|
||||||
return _to_project_file_out(pf)
|
return project_file_out(pf)
|
||||||
|
|
||||||
|
|
||||||
@router.delete("/projects/{slug}/files/{file_id}")
|
@router.delete("/projects/{slug}/files/{file_id}")
|
||||||
|
|||||||
@ -18,7 +18,7 @@ router = APIRouter(tags=["steps"])
|
|||||||
|
|
||||||
# --- Helpers ---
|
# --- Helpers ---
|
||||||
|
|
||||||
def _to_step_out(s: Step) -> StepOut:
|
def step_out(s: Step) -> StepOut:
|
||||||
"""Convert Step to StepOut schema."""
|
"""Convert Step to StepOut schema."""
|
||||||
return StepOut(
|
return StepOut(
|
||||||
id=str(s.id),
|
id=str(s.id),
|
||||||
@ -44,7 +44,7 @@ async def list_steps(task_id: str, db: AsyncSession = Depends(get_db)):
|
|||||||
result = await db.execute(
|
result = await db.execute(
|
||||||
select(Step).where(Step.task_id == uuid.UUID(task_id)).order_by(Step.position)
|
select(Step).where(Step.task_id == uuid.UUID(task_id)).order_by(Step.position)
|
||||||
)
|
)
|
||||||
return [_to_step_out(s) for s in result.scalars()]
|
return [step_out(s) for s in result.scalars()]
|
||||||
|
|
||||||
|
|
||||||
@router.post("/tasks/{task_id}/steps", response_model=StepOut)
|
@router.post("/tasks/{task_id}/steps", response_model=StepOut)
|
||||||
@ -67,7 +67,7 @@ async def create_step(task_id: str, req: StepCreate, db: AsyncSession = Depends(
|
|||||||
db.add(step)
|
db.add(step)
|
||||||
await db.commit()
|
await db.commit()
|
||||||
await db.refresh(step)
|
await db.refresh(step)
|
||||||
return _to_step_out(step)
|
return step_out(step)
|
||||||
|
|
||||||
|
|
||||||
@router.patch("/tasks/{task_id}/steps/{step_id}", response_model=StepOut)
|
@router.patch("/tasks/{task_id}/steps/{step_id}", response_model=StepOut)
|
||||||
@ -86,7 +86,7 @@ async def update_step(task_id: str, step_id: str, req: StepUpdate, db: AsyncSess
|
|||||||
|
|
||||||
await db.commit()
|
await db.commit()
|
||||||
await db.refresh(step)
|
await db.refresh(step)
|
||||||
return _to_step_out(step)
|
return step_out(step)
|
||||||
|
|
||||||
|
|
||||||
@router.delete("/tasks/{task_id}/steps/{step_id}")
|
@router.delete("/tasks/{task_id}/steps/{step_id}")
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user