Feature/add asset and asset sub class to search endpoint (#1795)
* Add asset and asset sub class to search endpoint * Update changelog
This commit is contained in:
parent
a0bec9e97f
commit
bd1963ec26
@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
||||||
|
- Added the asset and asset sub class to the search functionality
|
||||||
- Added the subscription expiration date to the users table of the admin control panel
|
- Added the subscription expiration date to the users table of the admin control panel
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
import { DataSource } from '@prisma/client';
|
import { AssetClass, AssetSubClass, DataSource } from '@prisma/client';
|
||||||
|
|
||||||
export interface LookupItem {
|
export interface LookupItem {
|
||||||
|
assetClass: AssetClass;
|
||||||
|
assetSubClass: AssetSubClass;
|
||||||
currency: string;
|
currency: string;
|
||||||
dataSource: DataSource;
|
dataSource: DataSource;
|
||||||
name: string;
|
name: string;
|
||||||
|
@ -176,6 +176,8 @@ export class CoinGeckoService implements DataProviderInterface {
|
|||||||
return {
|
return {
|
||||||
name,
|
name,
|
||||||
symbol,
|
symbol,
|
||||||
|
assetClass: AssetClass.CASH,
|
||||||
|
assetSubClass: AssetSubClass.CRYPTOCURRENCY,
|
||||||
currency: this.baseCurrency,
|
currency: this.baseCurrency,
|
||||||
dataSource: this.getName()
|
dataSource: this.getName()
|
||||||
};
|
};
|
||||||
|
@ -171,9 +171,25 @@ export class EodHistoricalDataService implements DataProviderInterface {
|
|||||||
.filter(({ symbol }) => {
|
.filter(({ symbol }) => {
|
||||||
return !symbol.toLowerCase().endsWith('forex');
|
return !symbol.toLowerCase().endsWith('forex');
|
||||||
})
|
})
|
||||||
.map(({ currency, dataSource, name, symbol }) => {
|
.map(
|
||||||
return { currency, dataSource, name, symbol };
|
({
|
||||||
})
|
assetClass,
|
||||||
|
assetSubClass,
|
||||||
|
currency,
|
||||||
|
dataSource,
|
||||||
|
name,
|
||||||
|
symbol
|
||||||
|
}) => {
|
||||||
|
return {
|
||||||
|
assetClass,
|
||||||
|
assetSubClass,
|
||||||
|
currency,
|
||||||
|
dataSource,
|
||||||
|
name,
|
||||||
|
symbol
|
||||||
|
};
|
||||||
|
}
|
||||||
|
)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -145,6 +145,8 @@ export class GoogleSheetsService implements DataProviderInterface {
|
|||||||
public async search(aQuery: string): Promise<{ items: LookupItem[] }> {
|
public async search(aQuery: string): Promise<{ items: LookupItem[] }> {
|
||||||
const items = await this.prismaService.symbolProfile.findMany({
|
const items = await this.prismaService.symbolProfile.findMany({
|
||||||
select: {
|
select: {
|
||||||
|
assetClass: true,
|
||||||
|
assetSubClass: true,
|
||||||
currency: true,
|
currency: true,
|
||||||
dataSource: true,
|
dataSource: true,
|
||||||
name: true,
|
name: true,
|
||||||
|
@ -165,6 +165,8 @@ export class ManualService implements DataProviderInterface {
|
|||||||
public async search(aQuery: string): Promise<{ items: LookupItem[] }> {
|
public async search(aQuery: string): Promise<{ items: LookupItem[] }> {
|
||||||
let items = await this.prismaService.symbolProfile.findMany({
|
let items = await this.prismaService.symbolProfile.findMany({
|
||||||
select: {
|
select: {
|
||||||
|
assetClass: true,
|
||||||
|
assetSubClass: true,
|
||||||
currency: true,
|
currency: true,
|
||||||
dataSource: true,
|
dataSource: true,
|
||||||
name: true,
|
name: true,
|
||||||
|
@ -101,9 +101,10 @@ export class YahooFinanceService implements DataProviderInterface {
|
|||||||
modules: ['price', 'summaryProfile', 'topHoldings']
|
modules: ['price', 'summaryProfile', 'topHoldings']
|
||||||
});
|
});
|
||||||
|
|
||||||
const { assetClass, assetSubClass } = this.parseAssetClass(
|
const { assetClass, assetSubClass } = this.parseAssetClass({
|
||||||
assetProfile.price
|
quoteType: assetProfile.price.quoteType,
|
||||||
);
|
shortName: assetProfile.price.shortName
|
||||||
|
});
|
||||||
|
|
||||||
response.assetClass = assetClass;
|
response.assetClass = assetClass;
|
||||||
response.assetSubClass = assetSubClass;
|
response.assetSubClass = assetSubClass;
|
||||||
@ -408,7 +409,14 @@ export class YahooFinanceService implements DataProviderInterface {
|
|||||||
marketDataItem.symbol
|
marketDataItem.symbol
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const { assetClass, assetSubClass } = this.parseAssetClass({
|
||||||
|
quoteType: quote.quoteType,
|
||||||
|
shortName: quote.shortname
|
||||||
|
});
|
||||||
|
|
||||||
items.push({
|
items.push({
|
||||||
|
assetClass,
|
||||||
|
assetSubClass,
|
||||||
symbol,
|
symbol,
|
||||||
currency: marketDataItem.currency,
|
currency: marketDataItem.currency,
|
||||||
dataSource: this.getName(),
|
dataSource: this.getName(),
|
||||||
@ -484,14 +492,20 @@ export class YahooFinanceService implements DataProviderInterface {
|
|||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
private parseAssetClass(aPrice: Price): {
|
private parseAssetClass({
|
||||||
|
quoteType,
|
||||||
|
shortName
|
||||||
|
}: {
|
||||||
|
quoteType: string;
|
||||||
|
shortName: string;
|
||||||
|
}): {
|
||||||
assetClass: AssetClass;
|
assetClass: AssetClass;
|
||||||
assetSubClass: AssetSubClass;
|
assetSubClass: AssetSubClass;
|
||||||
} {
|
} {
|
||||||
let assetClass: AssetClass;
|
let assetClass: AssetClass;
|
||||||
let assetSubClass: AssetSubClass;
|
let assetSubClass: AssetSubClass;
|
||||||
|
|
||||||
switch (aPrice?.quoteType?.toLowerCase()) {
|
switch (quoteType?.toLowerCase()) {
|
||||||
case 'cryptocurrency':
|
case 'cryptocurrency':
|
||||||
assetClass = AssetClass.CASH;
|
assetClass = AssetClass.CASH;
|
||||||
assetSubClass = AssetSubClass.CRYPTOCURRENCY;
|
assetSubClass = AssetSubClass.CRYPTOCURRENCY;
|
||||||
@ -509,10 +523,10 @@ export class YahooFinanceService implements DataProviderInterface {
|
|||||||
assetSubClass = AssetSubClass.COMMODITY;
|
assetSubClass = AssetSubClass.COMMODITY;
|
||||||
|
|
||||||
if (
|
if (
|
||||||
aPrice?.shortName?.toLowerCase()?.startsWith('gold') ||
|
shortName?.toLowerCase()?.startsWith('gold') ||
|
||||||
aPrice?.shortName?.toLowerCase()?.startsWith('palladium') ||
|
shortName?.toLowerCase()?.startsWith('palladium') ||
|
||||||
aPrice?.shortName?.toLowerCase()?.startsWith('platinum') ||
|
shortName?.toLowerCase()?.startsWith('platinum') ||
|
||||||
aPrice?.shortName?.toLowerCase()?.startsWith('silver')
|
shortName?.toLowerCase()?.startsWith('silver')
|
||||||
) {
|
) {
|
||||||
assetSubClass = AssetSubClass.PRECIOUS_METAL;
|
assetSubClass = AssetSubClass.PRECIOUS_METAL;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user