Reduce resource requests in assets page

This commit is contained in:
Diego Imbert
2025-07-08 17:13:57 +02:00
parent cb0910f158
commit b596d11a04
3 changed files with 16 additions and 4 deletions
+5
View File
@@ -12983,6 +12983,11 @@ paths:
$ref: "#/components/schemas/AssetUsageKind"
access_type:
$ref: "#/components/schemas/AssetUsageAccessType"
metadata:
type: object
properties:
resource_type:
type: string
/w/{workspace}/assets/list_by_usages:
post:
+10 -3
View File
@@ -22,15 +22,22 @@ async fn list_assets(
) -> JsonResult<Vec<Value>> {
let assets = sqlx::query_scalar!(
r#"SELECT
jsonb_build_object(
jsonb_strip_nulls(jsonb_build_object(
'path', path,
'kind', kind,
'usages', ARRAY_AGG(jsonb_build_object(
'path', usage_path,
'kind', usage_kind,
'access_type', usage_access_type
))
) as "list!: _"
)),
'metadata', (CASE
WHEN kind = 'resource' THEN
(SELECT jsonb_build_object('resource_type', resource_type) FROM resource WHERE resource.path = asset.path AND resource.workspace_id = $1)
ELSE
NULL
END
)
)) as "list!: _"
FROM asset
WHERE workspace_id = $1
GROUP BY path, kind
@@ -84,7 +84,7 @@
</a>
</Cell>
<Cell>
{#if assetCanBeExplored(asset, { resource_type: resourceTypesCache[asset.path] })}
{#if assetCanBeExplored(asset, asset.metadata)}
<ExploreAssetButton
{asset}
{s3FilePicker}