mirror of
https://github.com/dadosfera/maestro.git
synced 2026-09-19 00:44:48 +00:00
REFACTOR: add asset_type query parameter to getDataDocs and separate data docs methods
This commit is contained in:
@@ -423,6 +423,7 @@ export class CatalogController {
|
||||
@User() user: RequestUser,
|
||||
@Language() language: LanguageEnum,
|
||||
@Param('id') id: string,
|
||||
@Query('asset_type') asset_type: string,
|
||||
): Promise<IDocsResponse> {
|
||||
const { customer_name, customer_id, user_id, username } = user;
|
||||
|
||||
@@ -439,13 +440,7 @@ export class CatalogController {
|
||||
language,
|
||||
});
|
||||
|
||||
const { data_asset } = await this.catalogService.getOneDataAsset({
|
||||
customer_id,
|
||||
id,
|
||||
metadata,
|
||||
});
|
||||
|
||||
const docs = await this.catalogService.getDataDocs(id, data_asset.data_asset_type, metadata);
|
||||
const docs = await this.catalogService.getDataDocs(id, asset_type, metadata);
|
||||
|
||||
return { docs };
|
||||
}
|
||||
|
||||
@@ -340,10 +340,8 @@ class CatalogService implements OnModuleInit {
|
||||
}
|
||||
|
||||
async getDataDocs(id: string, assetType: string, metadata: Metadata) {
|
||||
const requestType = assetType === 'dataset' ? undefined : assetType;
|
||||
|
||||
const { documentation } = await lastValueFrom(
|
||||
this.catalogReadService.GetDatasetDoc({ id, type: requestType }, metadata),
|
||||
this.catalogReadService.GetDatasetDoc({ id }, metadata),
|
||||
);
|
||||
|
||||
const docs = JSON.parse(documentation);
|
||||
@@ -374,14 +372,24 @@ class CatalogService implements OnModuleInit {
|
||||
|
||||
async createDataDocs(body: CreateDataDocsDTO, metadata: Metadata) {
|
||||
if (body.asset_type === 'table' || body.asset_type === 'view') {
|
||||
const nimbusUrl = this._getNimbusUrl(body);
|
||||
const { data } = await axios.post(
|
||||
`${nimbusUrl}/api/catalog/data-docs/`,
|
||||
body,
|
||||
);
|
||||
return data;
|
||||
return this.createDataDocsViaNimbus(body);
|
||||
}
|
||||
|
||||
|
||||
return this.createDataDocsViaGrpc(body, metadata);
|
||||
}
|
||||
|
||||
private async createDataDocsViaNimbus(body: CreateDataDocsDTO) {
|
||||
this.logger.info('Creating data docs via Nimbus for table/view');
|
||||
const nimbusUrl = this._getNimbusUrl(body);
|
||||
const { data } = await axios.post(
|
||||
`${nimbusUrl}/api/catalog/data-docs/`,
|
||||
body,
|
||||
);
|
||||
return data;
|
||||
}
|
||||
|
||||
private async createDataDocsViaGrpc(body: CreateDataDocsDTO, metadata: Metadata) {
|
||||
this.logger.info('Creating data docs via gRPC for other asset types');
|
||||
try {
|
||||
const response: any = await lastValueFrom(
|
||||
this.catalogWriteService.UpdateDataAssetDoc(
|
||||
|
||||
Reference in New Issue
Block a user