FIX: Enhance searchDataAssets to convert owner names to IDs and log the conversion

This commit is contained in:
viniciusgadea
2025-12-15 09:08:08 -03:00
parent 1ff5589a2e
commit 918c3d7416
2 changed files with 35 additions and 0 deletions
+8
View File
@@ -4483,6 +4483,14 @@
"schema": {
"type": "string"
}
},
{
"name": "asset_type",
"required": true,
"in": "query",
"schema": {
"type": "string"
}
}
],
"responses": {
+27
View File
@@ -243,6 +243,33 @@ class CatalogService implements OnModuleInit {
const { search, page, size, sort_by, order, ...filters } = query;
if (filters.owner) {
const { users: customer_users } =
await this.userService.findAllUsersByCustomerId(customer_id);
const ownerValues = Array.isArray(filters.owner)
? filters.owner
: (typeof filters.owner === 'string' && filters.owner.includes(',')
? filters.owner.split(',').map((o: string) => o.trim())
: [filters.owner]);
const ownerIds = ownerValues
.map((ownerValue: string) => {
const user = customer_users.find(u =>
u.name === ownerValue || u.email === ownerValue || u.id === ownerValue
);
return user ? user.id : ownerValue;
})
.filter((id: string) => id);
filters.owner = ownerIds;
this.logger.info('Converted owner names to IDs:', {
original: ownerValues,
converted: ownerIds
});
}
const { data_assets, total } = await lastValueFrom(
this.catalogReadService.GetAllDataAssets(
{