|
|
@ -12,10 +12,10 @@ import { Sector } from '@ghostfolio/common/interfaces/sector.interface'; |
|
|
|
|
|
|
|
|
import { Injectable } from '@nestjs/common'; |
|
|
import { Injectable } from '@nestjs/common'; |
|
|
import { |
|
|
import { |
|
|
|
|
|
AssetProfileOverrides, |
|
|
DataSource, |
|
|
DataSource, |
|
|
Prisma, |
|
|
Prisma, |
|
|
SymbolProfile, |
|
|
SymbolProfile |
|
|
SymbolProfileOverrides |
|
|
|
|
|
} from '@prisma/client'; |
|
|
} from '@prisma/client'; |
|
|
import { continents, countries } from 'countries-list'; |
|
|
import { continents, countries } from 'countries-list'; |
|
|
|
|
|
|
|
|
@ -85,12 +85,12 @@ export class SymbolProfileService { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
return { |
|
|
return { |
|
|
SymbolProfileOverrides: { |
|
|
assetProfileOverrides: { |
|
|
upsert: { |
|
|
upsert: { |
|
|
create: |
|
|
create: |
|
|
data as Prisma.SymbolProfileOverridesCreateWithoutSymbolProfileInput, |
|
|
data as Prisma.AssetProfileOverridesCreateWithoutSymbolProfileInput, |
|
|
update: |
|
|
update: |
|
|
data as Prisma.SymbolProfileOverridesUpdateWithoutSymbolProfileInput |
|
|
data as Prisma.AssetProfileOverridesUpdateWithoutSymbolProfileInput |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
}; |
|
|
}; |
|
|
@ -112,7 +112,7 @@ export class SymbolProfileService { |
|
|
select: { date: true }, |
|
|
select: { date: true }, |
|
|
take: 1 |
|
|
take: 1 |
|
|
}, |
|
|
}, |
|
|
SymbolProfileOverrides: true |
|
|
assetProfileOverrides: true |
|
|
}, |
|
|
}, |
|
|
where: { |
|
|
where: { |
|
|
OR: aAssetProfileIdentifiers.map(({ dataSource, symbol }) => { |
|
|
OR: aAssetProfileIdentifiers.map(({ dataSource, symbol }) => { |
|
|
@ -137,7 +137,7 @@ export class SymbolProfileService { |
|
|
_count: { |
|
|
_count: { |
|
|
select: { activities: true, watchedBy: true } |
|
|
select: { activities: true, watchedBy: true } |
|
|
}, |
|
|
}, |
|
|
SymbolProfileOverrides: true |
|
|
assetProfileOverrides: true |
|
|
}, |
|
|
}, |
|
|
where: { |
|
|
where: { |
|
|
id: { |
|
|
id: { |
|
|
@ -174,6 +174,7 @@ export class SymbolProfileService { |
|
|
{ dataSource, symbol }: AssetProfileIdentifier, |
|
|
{ dataSource, symbol }: AssetProfileIdentifier, |
|
|
{ |
|
|
{ |
|
|
assetClass, |
|
|
assetClass, |
|
|
|
|
|
assetProfileOverrides, |
|
|
assetSubClass, |
|
|
assetSubClass, |
|
|
comment, |
|
|
comment, |
|
|
countries, |
|
|
countries, |
|
|
@ -185,13 +186,13 @@ export class SymbolProfileService { |
|
|
scraperConfiguration, |
|
|
scraperConfiguration, |
|
|
sectors, |
|
|
sectors, |
|
|
symbolMapping, |
|
|
symbolMapping, |
|
|
SymbolProfileOverrides, |
|
|
|
|
|
url |
|
|
url |
|
|
}: Prisma.SymbolProfileUpdateInput |
|
|
}: Prisma.SymbolProfileUpdateInput |
|
|
) { |
|
|
) { |
|
|
return this.prismaService.symbolProfile.update({ |
|
|
return this.prismaService.symbolProfile.update({ |
|
|
data: { |
|
|
data: { |
|
|
assetClass, |
|
|
assetClass, |
|
|
|
|
|
assetProfileOverrides, |
|
|
assetSubClass, |
|
|
assetSubClass, |
|
|
comment, |
|
|
comment, |
|
|
countries, |
|
|
countries, |
|
|
@ -203,7 +204,6 @@ export class SymbolProfileService { |
|
|
scraperConfiguration, |
|
|
scraperConfiguration, |
|
|
sectors, |
|
|
sectors, |
|
|
symbolMapping, |
|
|
symbolMapping, |
|
|
SymbolProfileOverrides, |
|
|
|
|
|
url |
|
|
url |
|
|
}, |
|
|
}, |
|
|
where: { dataSource_symbol: { dataSource, symbol } } |
|
|
where: { dataSource_symbol: { dataSource, symbol } } |
|
|
@ -216,13 +216,13 @@ export class SymbolProfileService { |
|
|
activities?: { |
|
|
activities?: { |
|
|
date: Date; |
|
|
date: Date; |
|
|
}[]; |
|
|
}[]; |
|
|
SymbolProfileOverrides: SymbolProfileOverrides; |
|
|
assetProfileOverrides: AssetProfileOverrides; |
|
|
})[] |
|
|
})[] |
|
|
): EnhancedSymbolProfile[] { |
|
|
): EnhancedSymbolProfile[] { |
|
|
return symbolProfiles.map((symbolProfile) => { |
|
|
return symbolProfiles.map((symbolProfile) => { |
|
|
const symbolProfileWithOverrides = applyAssetProfileOverrides( |
|
|
const symbolProfileWithOverrides = applyAssetProfileOverrides( |
|
|
symbolProfile, |
|
|
symbolProfile, |
|
|
symbolProfile.SymbolProfileOverrides |
|
|
symbolProfile.assetProfileOverrides |
|
|
); |
|
|
); |
|
|
|
|
|
|
|
|
const item = { |
|
|
const item = { |
|
|
@ -252,7 +252,7 @@ export class SymbolProfileService { |
|
|
item.dateOfFirstActivity = symbolProfile.activities?.[0]?.date; |
|
|
item.dateOfFirstActivity = symbolProfile.activities?.[0]?.date; |
|
|
delete item.activities; |
|
|
delete item.activities; |
|
|
|
|
|
|
|
|
delete item.SymbolProfileOverrides; |
|
|
delete item.assetProfileOverrides; |
|
|
|
|
|
|
|
|
return item; |
|
|
return item; |
|
|
}); |
|
|
}); |
|
|
|