Eliminate getSymbolProfilesBySymbols() (#1912)

pull/1915/head
Thomas Kaul 2 years ago committed by GitHub
parent 1326418ffc
commit e61b3b34a7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -492,13 +492,10 @@ export class PortfolioService {
symbol: position.symbol symbol: position.symbol
}; };
}); });
const symbols = currentPositions.positions.map(
(position) => position.symbol
);
const [dataProviderResponses, symbolProfiles] = await Promise.all([ const [dataProviderResponses, symbolProfiles] = await Promise.all([
this.dataProviderService.getQuotes(dataGatheringItems), this.dataProviderService.getQuotes(dataGatheringItems),
this.symbolProfileService.getSymbolProfilesBySymbols(symbols) this.symbolProfileService.getSymbolProfiles(dataGatheringItems)
]); ]);
const symbolProfileMap: { [symbol: string]: EnhancedSymbolProfile } = {}; const symbolProfileMap: { [symbol: string]: EnhancedSymbolProfile } = {};
@ -986,11 +983,13 @@ export class PortfolioService {
}; };
}); });
const symbols = positions.map((position) => position.symbol);
const [dataProviderResponses, symbolProfiles] = await Promise.all([ const [dataProviderResponses, symbolProfiles] = await Promise.all([
this.dataProviderService.getQuotes(dataGatheringItem), this.dataProviderService.getQuotes(dataGatheringItem),
this.symbolProfileService.getSymbolProfilesBySymbols(symbols) this.symbolProfileService.getSymbolProfiles(
positions.map(({ dataSource, symbol }) => {
return { dataSource, symbol };
})
)
]); ]);
const symbolProfileMap: { [symbol: string]: EnhancedSymbolProfile } = {}; const symbolProfileMap: { [symbol: string]: EnhancedSymbolProfile } = {};

@ -123,12 +123,9 @@ export class DataGatheringService {
const assetProfiles = await this.dataProviderService.getAssetProfiles( const assetProfiles = await this.dataProviderService.getAssetProfiles(
uniqueAssets uniqueAssets
); );
const symbolProfiles = const symbolProfiles = await this.symbolProfileService.getSymbolProfiles(
await this.symbolProfileService.getSymbolProfilesBySymbols( uniqueAssets
uniqueAssets.map(({ symbol }) => { );
return symbol;
})
);
for (const [symbol, assetProfile] of Object.entries(assetProfiles)) { for (const [symbol, assetProfile] of Object.entries(assetProfiles)) {
const symbolMapping = symbolProfiles.find((symbolProfile) => { const symbolMapping = symbolProfiles.find((symbolProfile) => {

@ -109,8 +109,14 @@ export class GoogleSheetsService implements DataProviderInterface {
try { try {
const response: { [symbol: string]: IDataProviderResponse } = {}; const response: { [symbol: string]: IDataProviderResponse } = {};
const symbolProfiles = const symbolProfiles = await this.symbolProfileService.getSymbolProfiles(
await this.symbolProfileService.getSymbolProfilesBySymbols(aSymbols); aSymbols.map((symbol) => {
return {
symbol,
dataSource: this.getName()
};
})
);
const sheet = await this.getSheet({ const sheet = await this.getSheet({
sheetId: this.configurationService.get('GOOGLE_SHEETS_ID'), sheetId: this.configurationService.get('GOOGLE_SHEETS_ID'),

@ -64,8 +64,9 @@ export class ManualService implements DataProviderInterface {
try { try {
const symbol = aSymbol; const symbol = aSymbol;
const [symbolProfile] = const [symbolProfile] = await this.symbolProfileService.getSymbolProfiles(
await this.symbolProfileService.getSymbolProfilesBySymbols([symbol]); [{ symbol, dataSource: this.getName() }]
);
const { defaultMarketPrice, selector, url } = const { defaultMarketPrice, selector, url } =
symbolProfile.scraperConfiguration ?? {}; symbolProfile.scraperConfiguration ?? {};
@ -128,8 +129,11 @@ export class ManualService implements DataProviderInterface {
} }
try { try {
const symbolProfiles = const symbolProfiles = await this.symbolProfileService.getSymbolProfiles(
await this.symbolProfileService.getSymbolProfilesBySymbols(aSymbols); aSymbols.map((symbol) => {
return { symbol, dataSource: this.getName() };
})
);
const marketData = await this.prismaService.marketData.findMany({ const marketData = await this.prismaService.marketData.findMany({
distinct: ['symbol'], distinct: ['symbol'],

@ -87,29 +87,6 @@ export class SymbolProfileService {
.then((symbolProfiles) => this.getSymbols(symbolProfiles)); .then((symbolProfiles) => this.getSymbols(symbolProfiles));
} }
/**
* @deprecated
*/
public async getSymbolProfilesBySymbols(
symbols: string[]
): Promise<EnhancedSymbolProfile[]> {
return this.prismaService.symbolProfile
.findMany({
include: {
_count: {
select: { Order: true }
},
SymbolProfileOverrides: true
},
where: {
symbol: {
in: symbols
}
}
})
.then((symbolProfiles) => this.getSymbols(symbolProfiles));
}
public updateSymbolProfile({ public updateSymbolProfile({
comment, comment,
dataSource, dataSource,

Loading…
Cancel
Save