- Unify API: lib/api.ts uses /api/v1, inbox uses /api/inbox (rewrites) - Remove localhost refs: openapi, inbox page - Add rewrites: /api/inbox|tmc -> inbox-server, /api/v1 -> FastAPI - Add stub routes: knowledge/insights, recommendations, search, log-error - Transfer from PAPA: prompts (inspection, tmc), scripts, supabase, data/tmc-requests - Fix inbox-server: ORDER BY created_at, package.json - Remove redundant app/api/inbox/files route (rewrites handle it) - knowledge/ in gitignore (large PDFs) Co-authored-by: Cursor <cursoragent@cursor.com>
40 lines
1.1 KiB
Python
40 lines
1.1 KiB
Python
|
|
from fastapi import APIRouter, Depends, Query
|
|
from sqlalchemy.orm import Session
|
|
from datetime import datetime
|
|
from typing import List
|
|
|
|
from app.db.session import get_db
|
|
from app.core.auth import get_current_user
|
|
from app.models.cert_application import CertApplication
|
|
from app.schemas.tasks import TaskOut
|
|
|
|
router = APIRouter(tags=["tasks"])
|
|
|
|
|
|
@router.get("/tasks", response_model=List[TaskOut])
|
|
def list_tasks(
|
|
state: str = Query(default="open"),
|
|
db: Session = Depends(get_db),
|
|
user=Depends(get_current_user),
|
|
):
|
|
q = db.query(CertApplication)
|
|
|
|
if state == "open":
|
|
q = q.filter(CertApplication.status.in_(["submitted", "under_review", "remarks"]))
|
|
|
|
apps = q.order_by(CertApplication.updated_at.desc()).all()
|
|
|
|
return [
|
|
TaskOut(
|
|
entity_type="cert_application",
|
|
entity_id=a.id,
|
|
title=f"Заявка №{a.number}",
|
|
status=a.status,
|
|
due_at=a.remarks_deadline_at,
|
|
priority="high" if a.remarks_deadline_at and a.remarks_deadline_at <= datetime.utcnow() else "normal",
|
|
updated_at=a.updated_at,
|
|
)
|
|
for a in apps
|
|
]
|