mirror of https://github.com/buster-so/buster.git
Update check-collections-containing-asset.ts
This commit is contained in:
parent
3cdd0bfa57
commit
e5dbf41db5
|
@ -13,6 +13,7 @@ import type {
|
|||
BusterMetricDataExtended,
|
||||
} from '@/api/asset_interfaces/metric';
|
||||
import { metricsQueryKeys } from '@/api/query_keys/metric';
|
||||
import { silenceAssetErrors } from '@/api/repsonse-helpers/silenece-asset-errors';
|
||||
import {
|
||||
getProtectedAssetPassword,
|
||||
setProtectedAssetPasswordError,
|
||||
|
@ -131,6 +132,7 @@ export const prefetchGetMetric = async (
|
|||
password: undefined,
|
||||
queryClient,
|
||||
}),
|
||||
retry: silenceAssetErrors,
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -11,19 +11,9 @@ export interface CollectionWithSharing {
|
|||
|
||||
export async function checkCollectionsContainingAsset(
|
||||
assetId: string,
|
||||
assetType: 'metric_file' | 'dashboard_file' | 'chat'
|
||||
assetType: Extract<AssetType, 'metric_file' | 'dashboard_file' | 'chat' | 'report_file'>
|
||||
): Promise<CollectionWithSharing[]> {
|
||||
// Map our asset type strings to the enum values expected by the database
|
||||
const assetTypeMap: Record<string, AssetType> = {
|
||||
metric: 'metric_file',
|
||||
dashboard: 'dashboard_file',
|
||||
chat: 'chat',
|
||||
};
|
||||
|
||||
const dbAssetType = assetTypeMap[assetType];
|
||||
if (!dbAssetType) {
|
||||
throw new Error(`Invalid asset type: ${assetType}`);
|
||||
}
|
||||
// The asset type parameter already matches the AssetType enum values
|
||||
|
||||
const result = await db
|
||||
.select({
|
||||
|
@ -36,7 +26,7 @@ export async function checkCollectionsContainingAsset(
|
|||
.where(
|
||||
and(
|
||||
eq(collectionsToAssets.assetId, assetId),
|
||||
eq(collectionsToAssets.assetType, dbAssetType),
|
||||
eq(collectionsToAssets.assetType, assetType),
|
||||
isNull(collectionsToAssets.deletedAt),
|
||||
isNull(collections.deletedAt)
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue