Browse Source

Fix creation of asset profiles with symbol in wrong letter case by using original symbol

pull/7727/head
Thomas Kaul 3 days ago
parent
commit
a6124891e7
  1. 22
      apps/api/src/app/activities/activities.controller.ts
  2. 16
      apps/api/src/app/endpoints/watchlist/watchlist.service.ts
  3. 4
      apps/api/src/services/data-provider/data-provider.service.ts
  4. 10
      apps/api/src/services/queues/data-gathering/data-gathering.service.ts

22
apps/api/src/app/activities/activities.controller.ts

@ -12,6 +12,7 @@ import { getIntervalFromDateRange } from '@ghostfolio/common/calculation-helper'
import { DATA_GATHERING_QUEUE_PRIORITY_HIGH } from '@ghostfolio/common/config';
import { CreateOrderDto, UpdateOrderDto } from '@ghostfolio/common/dtos';
import { SubscriptionType } from '@ghostfolio/common/enums';
import { getAssetProfileIdentifier } from '@ghostfolio/common/helper';
import {
ActivitiesResponse,
ActivityResponse
@ -32,7 +33,7 @@ import {
Query,
UseInterceptors
} from '@nestjs/common';
import { Order } from '@prisma/client';
import { Order, SymbolProfile } from '@prisma/client';
import { parseISO } from 'date-fns';
import { StatusCodes, getReasonPhrase } from 'http-status-codes';
@ -224,8 +225,12 @@ export class ActivitiesController {
? userSubscription
: authenticatedUserSubscription;
let assetProfiles: {
[assetProfileIdentifier: string]: Partial<SymbolProfile>;
};
try {
await this.dataProviderService.validateActivities({
assetProfiles = await this.dataProviderService.validateActivities({
subscription,
activitiesDto: [
{
@ -251,6 +256,11 @@ export class ActivitiesController {
const customCurrency = data.customCurrency;
const dataSource = data.dataSource;
const symbol =
assetProfiles[
getAssetProfileIdentifier({ dataSource, symbol: data.symbol })
]?.symbol ?? data.symbol;
if (customCurrency) {
data.currency = customCurrency;
@ -268,12 +278,12 @@ export class ActivitiesController {
create: {
currency,
dataSource,
symbol: data.symbol
symbol
},
where: {
dataSource_symbol: {
dataSource,
symbol: data.symbol
symbol
}
}
}
@ -291,8 +301,8 @@ export class ActivitiesController {
dataGatheringItems: [
{
dataSource,
date: activity.date,
symbol: data.symbol
symbol,
date: activity.date
}
],
priority: DATA_GATHERING_QUEUE_PRIORITY_HIGH

16
apps/api/src/app/endpoints/watchlist/watchlist.service.ts

@ -26,10 +26,12 @@ export class WatchlistService {
public async createWatchlistItem({
dataSource,
symbol,
symbol: aSymbol,
userId
}: { userId: string } & AssetProfileIdentifier): Promise<void> {
const symbolProfile = await this.prismaService.symbolProfile.findUnique({
let symbol = aSymbol;
let symbolProfile = await this.prismaService.symbolProfile.findUnique({
where: {
dataSource_symbol: { dataSource, symbol }
}
@ -49,10 +51,20 @@ export class WatchlistService {
);
}
symbol = assetProfile.symbol;
symbolProfile = await this.prismaService.symbolProfile.findUnique({
where: {
dataSource_symbol: { dataSource, symbol }
}
});
if (!symbolProfile) {
await this.symbolProfileService.add(
assetProfile as Prisma.SymbolProfileCreateInput
);
}
}
await this.dataGatheringService.gatherSymbol({
dataSource,

4
apps/api/src/services/data-provider/data-provider.service.ts

@ -130,8 +130,8 @@ export class DataProviderService implements OnModuleInit {
})
] = {
...assetProfile,
symbol,
name: formatAssetProfileName(assetProfile)
name: formatAssetProfileName(assetProfile),
symbol: assetProfile.symbol ?? symbol
};
}
})

10
apps/api/src/services/queues/data-gathering/data-gathering.service.ts

@ -95,8 +95,13 @@ export class DataGatheringService {
assetProfileIdentifiers
);
for (const assetProfile of Object.values(assetProfiles)) {
const { symbol } = assetProfile;
for (const { dataSource, symbol } of assetProfileIdentifiers) {
const assetProfile =
assetProfiles[getAssetProfileIdentifier({ dataSource, symbol })];
if (!assetProfile) {
continue;
}
const symbolProfile = symbolProfiles.find(
({ symbol: symbolProfileSymbol }) => {
@ -137,7 +142,6 @@ export class DataGatheringService {
countries,
currency,
cusip,
dataSource,
figi,
figiComposite,
figiShareClass,

Loading…
Cancel
Save