|
|
@ -18,45 +18,46 @@ export class AssetProfilesService { |
|
|
{ dataSource, symbol }: AssetProfileIdentifier, |
|
|
{ dataSource, symbol }: AssetProfileIdentifier, |
|
|
assetProfileData: UpdateAssetProfileDataDto |
|
|
assetProfileData: UpdateAssetProfileDataDto |
|
|
): Promise<EnhancedSymbolProfile> { |
|
|
): Promise<EnhancedSymbolProfile> { |
|
|
const [assetProfile] = await this.symbolProfileService.getSymbolProfiles([ |
|
|
const notFoundMessage = `Could not find the asset profile for ${symbol} (${dataSource})`; |
|
|
{ |
|
|
|
|
|
dataSource, |
|
|
|
|
|
symbol |
|
|
|
|
|
} |
|
|
|
|
|
]); |
|
|
|
|
|
|
|
|
|
|
|
if (!assetProfile) { |
|
|
|
|
|
throw new NotFoundException( |
|
|
|
|
|
`Could not find the asset profile for ${symbol} (${dataSource})` |
|
|
|
|
|
); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const data = this.getAssetProfileDataUpdate(assetProfileData); |
|
|
const data = this.getAssetProfileDataUpdate(assetProfileData); |
|
|
|
|
|
|
|
|
if (Object.keys(data).length === 0) { |
|
|
if (Object.keys(data).length > 0) { |
|
|
return assetProfile; |
|
|
try { |
|
|
|
|
|
await this.symbolProfileService.updateSymbolProfile( |
|
|
|
|
|
{ |
|
|
|
|
|
dataSource, |
|
|
|
|
|
symbol |
|
|
|
|
|
}, |
|
|
|
|
|
this.symbolProfileService.getAssetProfileUpdateInput( |
|
|
|
|
|
{ dataSource, symbol }, |
|
|
|
|
|
data |
|
|
|
|
|
) |
|
|
|
|
|
); |
|
|
|
|
|
} catch (error) { |
|
|
|
|
|
if ( |
|
|
|
|
|
error instanceof Prisma.PrismaClientKnownRequestError && |
|
|
|
|
|
error.code === 'P2025' |
|
|
|
|
|
) { |
|
|
|
|
|
throw new NotFoundException(notFoundMessage); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
throw error; |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
await this.symbolProfileService.updateSymbolProfile( |
|
|
const [assetProfile] = await this.symbolProfileService.getSymbolProfiles([ |
|
|
{ |
|
|
{ |
|
|
dataSource, |
|
|
dataSource, |
|
|
symbol |
|
|
symbol |
|
|
}, |
|
|
} |
|
|
this.symbolProfileService.getAssetProfileUpdateInput( |
|
|
]); |
|
|
{ dataSource, symbol }, |
|
|
|
|
|
data |
|
|
|
|
|
) |
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
const [updatedAssetProfile] = |
|
|
if (!assetProfile) { |
|
|
await this.symbolProfileService.getSymbolProfiles([ |
|
|
throw new NotFoundException(notFoundMessage); |
|
|
{ |
|
|
} |
|
|
dataSource, |
|
|
|
|
|
symbol |
|
|
|
|
|
} |
|
|
|
|
|
]); |
|
|
|
|
|
|
|
|
|
|
|
return updatedAssetProfile; |
|
|
return assetProfile; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private getAssetProfileDataUpdate({ |
|
|
private getAssetProfileDataUpdate({ |
|
|
|