FIX: Get user by id unkown error

This commit is contained in:
Victor Radael
2022-10-03 16:45:50 -03:00
parent fe261667f8
commit dade8d59e5
3 changed files with 25 additions and 22 deletions
+4 -4
View File
@@ -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,
+20 -17
View File
@@ -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
View File
File diff suppressed because one or more lines are too long