mirror of
https://github.com/dadosfera/maestro.git
synced 2026-10-23 19:19:07 +00:00
FIX: Get user by id unkown error
This commit is contained in:
@@ -16,10 +16,10 @@ export class CatalogClientConfiguration {
|
||||
Catalog.ProtoPackages.ReadPackage,
|
||||
Catalog.ProtoPackages.WritePackage,
|
||||
],
|
||||
credentials:
|
||||
process.env.LOCAL_ENV || process.env.ENV === 'local'
|
||||
? undefined
|
||||
: credentials.createSsl(),
|
||||
// credentials:
|
||||
// process.env.LOCAL_ENV || process.env.ENV === 'local'
|
||||
// ? undefined
|
||||
// : credentials.createSsl(),
|
||||
protoPath: [
|
||||
Catalog.ProtoPaths.ReadFilePath,
|
||||
Catalog.ProtoPaths.WriteFilePath,
|
||||
|
||||
@@ -112,7 +112,7 @@ class CatalogService implements OnModuleInit {
|
||||
}
|
||||
|
||||
async getUserRolesIds(userId: string) {
|
||||
const result = await this.userService.findOneById(userId);
|
||||
const result = await this.userService.findOneById(userId).catch(() => null);
|
||||
|
||||
const roles_ids = result.user.roles.map((role) => role.id);
|
||||
|
||||
@@ -154,24 +154,23 @@ class CatalogService implements OnModuleInit {
|
||||
|
||||
const response = await lastValueFrom(
|
||||
this.catalogReadService.GetAllDataAssets(data, metadata),
|
||||
)
|
||||
.then((res) => {
|
||||
this.logger.info('Done');
|
||||
return JSON.parse(res.data_assets);
|
||||
})
|
||||
.catch((err) => {
|
||||
this.logger.error(err.message);
|
||||
throw new Error(err);
|
||||
});
|
||||
).catch((err) => {
|
||||
throw new HttpException(
|
||||
err.details,
|
||||
err.code === 6 ? HttpStatus.CONFLICT : 404,
|
||||
);
|
||||
});
|
||||
|
||||
const data_assets = JSON.parse(response.data_assets);
|
||||
|
||||
const [customer_users, customer_roles] =
|
||||
await this.getUsernamesAndRolesByCustomerId(customer_id);
|
||||
|
||||
for (const asset of response.tables) {
|
||||
for (const asset of data_assets.tables) {
|
||||
const condition =
|
||||
asset.owner && !asset.owner.includes('@') ? true : false;
|
||||
const result = condition
|
||||
? await this.userService.findOneById(asset.owner)
|
||||
? await this.userService.findOneById(asset.owner).catch(() => null)
|
||||
: null;
|
||||
|
||||
const owner = result !== null ? result.user.username : null;
|
||||
@@ -194,11 +193,11 @@ class CatalogService implements OnModuleInit {
|
||||
Object.assign(asset, { ...asset, owner, roles, users });
|
||||
}
|
||||
|
||||
for (const asset of response.dashboards) {
|
||||
for (const asset of data_assets.dashboards) {
|
||||
const condition =
|
||||
asset.owner && !asset.owner.includes('@') ? true : false;
|
||||
const result = condition
|
||||
? await this.userService.findOneById(asset.owner)
|
||||
? await this.userService.findOneById(asset.owner).catch(() => null)
|
||||
: null;
|
||||
|
||||
const owner = result !== null ? result.user.username : null;
|
||||
@@ -206,7 +205,7 @@ class CatalogService implements OnModuleInit {
|
||||
Object.assign(asset, { ...asset, owner });
|
||||
}
|
||||
|
||||
return { data_assets: response };
|
||||
return { data_assets };
|
||||
}
|
||||
|
||||
async getOneDashboardMetabase(id, body, metadata, customer_id) {
|
||||
@@ -224,7 +223,9 @@ class CatalogService implements OnModuleInit {
|
||||
const opensearchTable = JSON.parse(data_asset);
|
||||
|
||||
const result = opensearchTable.owner
|
||||
? await this.userService.findOneById(opensearchTable.owner)
|
||||
? await this.userService
|
||||
.findOneById(opensearchTable.owner)
|
||||
.catch(() => null)
|
||||
: null;
|
||||
|
||||
const owner = result !== null ? result.user.username : null;
|
||||
@@ -280,7 +281,9 @@ class CatalogService implements OnModuleInit {
|
||||
);
|
||||
const opensearchTable = JSON.parse(data_asset);
|
||||
const result = opensearchTable.owner
|
||||
? await this.userService.findOneById(opensearchTable.owner)
|
||||
? await this.userService
|
||||
.findOneById(opensearchTable.owner)
|
||||
.catch(() => null)
|
||||
: null;
|
||||
|
||||
const owner = result !== null ? result.user.username : null;
|
||||
|
||||
+1
-1
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user