perf(workflow): page scope references

This commit is contained in:
2026-07-30 01:30:38 +02:00
parent c45e2b808c
commit a1654e70cf
2 changed files with 17 additions and 3 deletions
+9 -3
View File
@@ -10,7 +10,7 @@ from govoplan_core.api.v1.schemas import (
from govoplan_core.audit.logging import audit_event
from govoplan_core.auth import ApiPrincipal, get_api_principal, has_scope
from govoplan_core.core.references import (
access_scope_reference_options,
access_scope_reference_page,
access_scope_reference_provider_available,
validate_access_scope_reference,
)
@@ -225,6 +225,8 @@ def api_scope_targets(
q: str = "",
selected: list[str] = Query(default=[]),
limit: int = Query(default=50, ge=1, le=200),
cursor: str | None = None,
session: Session = Depends(get_session),
principal: ApiPrincipal = Depends(get_api_principal),
) -> ReferenceOptionListResponse:
_require_any_scope(
@@ -235,14 +237,16 @@ def api_scope_targets(
)
registry = get_registry()
try:
options = access_scope_reference_options(
page = access_scope_reference_page(
registry,
principal,
scope_type=scope_type,
query=q,
selected_values=selected,
limit=limit,
cursor=cursor,
administrative=has_scope(principal, ADMIN_SCOPE),
session=session,
)
except ValueError as exc:
raise HTTPException(
@@ -250,8 +254,10 @@ def api_scope_targets(
detail=str(exc),
) from exc
return ReferenceOptionListResponse(
options=[ReferenceOptionResponse(**item.to_dict()) for item in options],
options=[ReferenceOptionResponse(**item.to_dict()) for item in page.options],
provider_available=access_scope_reference_provider_available(registry),
next_cursor=page.next_cursor,
has_more=page.has_more,
)