mirror of
https://github.com/dadosfera/maestro.git
synced 2026-10-15 14:19:08 +00:00
FIX: Enhance searchDataAssets to convert owner names to IDs and log the conversion
This commit is contained in:
@@ -4483,6 +4483,14 @@
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "asset_type",
|
||||
"required": true,
|
||||
"in": "query",
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
|
||||
@@ -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(
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user