chore: snapshot before HartOMat rebrand
This commit is contained in:
@@ -212,6 +212,50 @@ async def stream_render_log(
|
||||
from fastapi import status as http_status
|
||||
|
||||
|
||||
@router.post("/activity/dismiss-failed", status_code=http_status.HTTP_200_OK)
|
||||
async def dismiss_all_failed(
|
||||
user: User = Depends(require_admin_or_pm),
|
||||
db: AsyncSession = Depends(get_db),
|
||||
):
|
||||
"""Reset all failed render jobs and CAD files so they stop showing as failures."""
|
||||
from sqlalchemy import update as sql_update
|
||||
|
||||
render_result = await db.execute(
|
||||
sql_update(OrderLine)
|
||||
.where(OrderLine.render_status == "failed")
|
||||
.values(render_status="cancelled")
|
||||
)
|
||||
cad_result = await db.execute(
|
||||
sql_update(CadFile)
|
||||
.where(CadFile.processing_status == ProcessingStatus.failed)
|
||||
.values(processing_status=ProcessingStatus.pending)
|
||||
)
|
||||
await db.commit()
|
||||
return {"dismissed_renders": render_result.rowcount, "dismissed_cad": cad_result.rowcount}
|
||||
|
||||
|
||||
@router.post("/activity/dismiss-render/{order_line_id}", status_code=http_status.HTTP_200_OK)
|
||||
async def dismiss_single_failed_render(
|
||||
order_line_id: str,
|
||||
user: User = Depends(require_admin_or_pm),
|
||||
db: AsyncSession = Depends(get_db),
|
||||
):
|
||||
"""Dismiss a single failed render job by setting its status to 'cancelled'."""
|
||||
result = await db.execute(
|
||||
select(OrderLine).where(
|
||||
OrderLine.id == order_line_id,
|
||||
OrderLine.render_status == "failed",
|
||||
)
|
||||
)
|
||||
line = result.scalar_one_or_none()
|
||||
if not line:
|
||||
raise HTTPException(404, detail="Failed render job not found")
|
||||
|
||||
line.render_status = "cancelled"
|
||||
await db.commit()
|
||||
return {"dismissed": order_line_id}
|
||||
|
||||
|
||||
@router.post("/activity/{cad_file_id}/reprocess", status_code=http_status.HTTP_202_ACCEPTED)
|
||||
async def reprocess_cad_file(
|
||||
cad_file_id: str,
|
||||
|
||||
Reference in New Issue
Block a user