- session: set_tenant use bound param (SQL injection fix)
- health: text('SELECT 1'), REDIS_URL from config
- deps: re-export get_db from session, use settings.ENABLE_DEV_AUTH (default False)
- routes: all get_db from app.api.deps; conftest overrides deps.get_db
- main: register exception handlers from app.api.exceptions
- next.config: enable ESLint and TypeScript checks
- .eslintrc: drop @typescript-eslint/recommended; fix no-console (logger, ws-client, regulations)
- backend/.env.example added
- frontend: export apiFetch; dashboard, profile, settings, risks use api-client
- docs/ANALYSIS_AND_RECOMMENDATIONS.md
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.api.deps 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(prefix="/api/v1", 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
|
|
]
|