mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-09-11 08:07:15 +00:00
Reduce resource requests in assets page
This commit is contained in:
@@ -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:
|
||||
|
||||
@@ -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}
|
||||
|
||||
Reference in New Issue
Block a user