mirror of https://github.com/ghostfolio/ghostfolio
9 changed files with 113 additions and 53 deletions
@ -0,0 +1,29 @@ |
|||
import { SECTORS, UNKNOWN_KEY } from '@ghostfolio/common/config'; |
|||
|
|||
import { Logger } from '@nestjs/common'; |
|||
|
|||
export function getSectorName({ |
|||
aliases = {}, |
|||
name |
|||
}: { |
|||
aliases?: Record<string, string>; |
|||
name: string; |
|||
}): string { |
|||
const mappedName = aliases[name]; |
|||
|
|||
if (mappedName) { |
|||
return mappedName; |
|||
} |
|||
|
|||
if ((SECTORS as readonly string[]).includes(name)) { |
|||
return name; |
|||
} |
|||
|
|||
if (name) { |
|||
const logger = new Logger('getSectorName'); |
|||
|
|||
logger.warn(`Could not map the sector "${name}" to the ontology`); |
|||
} |
|||
|
|||
return UNKNOWN_KEY; |
|||
} |
|||
@ -0,0 +1,13 @@ |
|||
export type SectorName = |
|||
| 'Basic Materials' |
|||
| 'Communication Services' |
|||
| 'Consumer Cyclical' |
|||
| 'Consumer Defensive' |
|||
| 'Energy' |
|||
| 'Financial Services' |
|||
| 'Healthcare' |
|||
| 'Industrials' |
|||
| 'Other' |
|||
| 'Real Estate' |
|||
| 'Technology' |
|||
| 'Utilities'; |
|||
Loading…
Reference in new issue