Feature/refactor unique asset type to asset profile identifier (#3636)
* Refactoring
This commit is contained in:
@@ -19,7 +19,7 @@ import {
|
||||
ghostfolioScraperApiSymbolPrefix,
|
||||
locale
|
||||
} from './config';
|
||||
import { Benchmark, UniqueAsset } from './interfaces';
|
||||
import { AssetProfileIdentifier, Benchmark } from './interfaces';
|
||||
import { BenchmarkTrend, ColorScheme } from './types';
|
||||
|
||||
export const DATE_FORMAT = 'yyyy-MM-dd';
|
||||
@@ -147,7 +147,10 @@ export function getAllActivityTypes(): ActivityType[] {
|
||||
return Object.values(ActivityType);
|
||||
}
|
||||
|
||||
export function getAssetProfileIdentifier({ dataSource, symbol }: UniqueAsset) {
|
||||
export function getAssetProfileIdentifier({
|
||||
dataSource,
|
||||
symbol
|
||||
}: AssetProfileIdentifier) {
|
||||
return `${dataSource}-${symbol}`;
|
||||
}
|
||||
|
||||
@@ -377,7 +380,7 @@ export function parseDate(date: string): Date | null {
|
||||
return parseISO(date);
|
||||
}
|
||||
|
||||
export function parseSymbol({ dataSource, symbol }: UniqueAsset) {
|
||||
export function parseSymbol({ dataSource, symbol }: AssetProfileIdentifier) {
|
||||
const [ticker, exchange] = symbol.split('.');
|
||||
|
||||
return {
|
||||
|
@@ -1,13 +1,13 @@
|
||||
import { Role } from '@prisma/client';
|
||||
import { AssetProfileIdentifier } from '@ghostfolio/common/interfaces';
|
||||
|
||||
import { UniqueAsset } from './unique-asset.interface';
|
||||
import { Role } from '@prisma/client';
|
||||
|
||||
export interface AdminData {
|
||||
exchangeRates: ({
|
||||
label1: string;
|
||||
label2: string;
|
||||
value: number;
|
||||
} & UniqueAsset)[];
|
||||
} & AssetProfileIdentifier)[];
|
||||
settings: { [key: string]: boolean | object | string | string[] };
|
||||
transactionCount: number;
|
||||
userCount: number;
|
||||
|
@@ -1,6 +1,6 @@
|
||||
import { DataSource } from '@prisma/client';
|
||||
|
||||
export interface UniqueAsset {
|
||||
export interface AssetProfileIdentifier {
|
||||
dataSource: DataSource;
|
||||
symbol: string;
|
||||
}
|
@@ -7,6 +7,7 @@ import type {
|
||||
AdminMarketData,
|
||||
AdminMarketDataItem
|
||||
} from './admin-market-data.interface';
|
||||
import type { AssetProfileIdentifier } from './asset-profile-identifier.interface';
|
||||
import type { BenchmarkMarketDataDetails } from './benchmark-market-data-details.interface';
|
||||
import type { BenchmarkProperty } from './benchmark-property.interface';
|
||||
import type { Benchmark } from './benchmark.interface';
|
||||
@@ -48,7 +49,6 @@ import type { Subscription } from './subscription.interface';
|
||||
import type { SymbolMetrics } from './symbol-metrics.interface';
|
||||
import type { SystemMessage } from './system-message.interface';
|
||||
import type { TabConfiguration } from './tab-configuration.interface';
|
||||
import type { UniqueAsset } from './unique-asset.interface';
|
||||
import type { UserSettings } from './user-settings.interface';
|
||||
import type { User } from './user.interface';
|
||||
|
||||
@@ -61,6 +61,7 @@ export {
|
||||
AdminMarketData,
|
||||
AdminMarketDataDetails,
|
||||
AdminMarketDataItem,
|
||||
AssetProfileIdentifier,
|
||||
Benchmark,
|
||||
BenchmarkMarketDataDetails,
|
||||
BenchmarkProperty,
|
||||
@@ -101,7 +102,6 @@ export {
|
||||
Subscription,
|
||||
SymbolMetrics,
|
||||
TabConfiguration,
|
||||
UniqueAsset,
|
||||
User,
|
||||
UserSettings
|
||||
};
|
||||
|
@@ -1,6 +1,6 @@
|
||||
import { UniqueAsset } from '../unique-asset.interface';
|
||||
import { AssetProfileIdentifier } from '@ghostfolio/common/interfaces';
|
||||
|
||||
export interface ResponseError {
|
||||
errors?: UniqueAsset[];
|
||||
errors?: AssetProfileIdentifier[];
|
||||
hasErrors: boolean;
|
||||
}
|
||||
|
@@ -1,5 +1,5 @@
|
||||
import { transformToBig } from '@ghostfolio/common/class-transformer';
|
||||
import { UniqueAsset } from '@ghostfolio/common/interfaces';
|
||||
import { AssetProfileIdentifier } from '@ghostfolio/common/interfaces';
|
||||
import { TimelinePosition } from '@ghostfolio/common/models';
|
||||
|
||||
import { Big } from 'big.js';
|
||||
@@ -9,7 +9,7 @@ export class PortfolioSnapshot {
|
||||
@Transform(transformToBig, { toClassOnly: true })
|
||||
@Type(() => Big)
|
||||
currentValueInBaseCurrency: Big;
|
||||
errors?: UniqueAsset[];
|
||||
errors?: AssetProfileIdentifier[];
|
||||
|
||||
@Transform(transformToBig, { toClassOnly: true })
|
||||
@Type(() => Big)
|
||||
|
Reference in New Issue
Block a user