feat(search): add global titlebar search filters

This commit is contained in:
2026-07-29 22:01:18 +02:00
parent 6fcd9e0e65
commit bed704eb7a
8 changed files with 477 additions and 61 deletions
+36 -2
View File
@@ -18,6 +18,7 @@ from govoplan_search.backend.schemas import (
SearchProviderListResponse,
SearchProviderResponse,
SearchRebuildResponse,
SearchResourceTypeResponse,
SearchResponse,
SearchResultResponse,
)
@@ -68,6 +69,37 @@ def _service(registry: PlatformRegistry) -> SearchIndexService:
return capability
def _search_resource_catalogue(
registry: PlatformRegistry,
) -> list[SearchResourceTypeResponse]:
resources = {
(
descriptor.module_id,
descriptor.resource_type,
descriptor.provider_id,
): SearchResourceTypeResponse(
provider_id=descriptor.provider_id,
module_id=descriptor.module_id,
resource_type=descriptor.resource_type,
label=descriptor.label,
order=registered.registration.order,
)
for registered, source in registry.search_sources()
for descriptor in source.resource_types()
}
return [
resources[key]
for key in sorted(
resources,
key=lambda item: (
resources[item].order,
resources[item].label.casefold(),
item,
),
)
]
@router.get("", response_model=SearchResponse)
def api_search(
request: Request,
@@ -152,7 +184,8 @@ def api_search_providers(
principal: ApiPrincipal = Depends(get_api_principal),
) -> SearchProviderListResponse:
_require_read(principal)
registrations = _registry(request).search_provider_registrations()
registry = _registry(request)
registrations = registry.search_provider_registrations()
return SearchProviderListResponse(
providers=[
SearchProviderResponse(
@@ -162,7 +195,8 @@ def api_search_providers(
order=item.registration.order,
)
for item in registrations
]
],
resources=_search_resource_catalogue(registry),
)