mirror of
https://github.com/dadosfera/maestro.git
synced 2026-11-28 00:10:05 +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,
|
@User() user: RequestUser,
|
||||||
@Language() language: LanguageEnum,
|
@Language() language: LanguageEnum,
|
||||||
@Param('id') id: string,
|
@Param('id') id: string,
|
||||||
|
@Query('asset_type') asset_type: string,
|
||||||
): Promise<IDocsResponse> {
|
): Promise<IDocsResponse> {
|
||||||
const { customer_name, customer_id, user_id, username } = user;
|
const { customer_name, customer_id, user_id, username } = user;
|
||||||
|
|
||||||
@@ -439,13 +440,7 @@ export class CatalogController {
|
|||||||
language,
|
language,
|
||||||
});
|
});
|
||||||
|
|
||||||
const { data_asset } = await this.catalogService.getOneDataAsset({
|
const docs = await this.catalogService.getDataDocs(id, asset_type, metadata);
|
||||||
customer_id,
|
|
||||||
id,
|
|
||||||
metadata,
|
|
||||||
});
|
|
||||||
|
|
||||||
const docs = await this.catalogService.getDataDocs(id, data_asset.data_asset_type, metadata);
|
|
||||||
|
|
||||||
return { docs };
|
return { docs };
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -340,10 +340,8 @@ class CatalogService implements OnModuleInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async getDataDocs(id: string, assetType: string, metadata: Metadata) {
|
async getDataDocs(id: string, assetType: string, metadata: Metadata) {
|
||||||
const requestType = assetType === 'dataset' ? undefined : assetType;
|
|
||||||
|
|
||||||
const { documentation } = await lastValueFrom(
|
const { documentation } = await lastValueFrom(
|
||||||
this.catalogReadService.GetDatasetDoc({ id, type: requestType }, metadata),
|
this.catalogReadService.GetDatasetDoc({ id }, metadata),
|
||||||
);
|
);
|
||||||
|
|
||||||
const docs = JSON.parse(documentation);
|
const docs = JSON.parse(documentation);
|
||||||
@@ -374,14 +372,24 @@ class CatalogService implements OnModuleInit {
|
|||||||
|
|
||||||
async createDataDocs(body: CreateDataDocsDTO, metadata: Metadata) {
|
async createDataDocs(body: CreateDataDocsDTO, metadata: Metadata) {
|
||||||
if (body.asset_type === 'table' || body.asset_type === 'view') {
|
if (body.asset_type === 'table' || body.asset_type === 'view') {
|
||||||
const nimbusUrl = this._getNimbusUrl(body);
|
return this.createDataDocsViaNimbus(body);
|
||||||
const { data } = await axios.post(
|
|
||||||
`${nimbusUrl}/api/catalog/data-docs/`,
|
|
||||||
body,
|
|
||||||
);
|
|
||||||
return data;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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 {
|
try {
|
||||||
const response: any = await lastValueFrom(
|
const response: any = await lastValueFrom(
|
||||||
this.catalogWriteService.UpdateDataAssetDoc(
|
this.catalogWriteService.UpdateDataAssetDoc(
|
||||||
|
|||||||
Reference in New Issue
Block a user