Task/harmonize sector names accross data providers (#6994)
* Harmonize sector names * Update changelogpull/6902/head
parent
bf7409ec20
commit
3a4b0ce304
@ -0,0 +1,28 @@
|
||||
import { SECTORS } from '@ghostfolio/common/config';
|
||||
import { SectorName } from '@ghostfolio/common/types';
|
||||
|
||||
import { Logger } from '@nestjs/common';
|
||||
|
||||
export function getSectorName({
|
||||
aliases = {},
|
||||
name
|
||||
}: {
|
||||
aliases?: Record<string, SectorName>;
|
||||
name: string;
|
||||
}): SectorName {
|
||||
if (aliases[name]) {
|
||||
return aliases[name];
|
||||
}
|
||||
|
||||
if ((SECTORS as readonly string[]).includes(name)) {
|
||||
return name as SectorName;
|
||||
}
|
||||
|
||||
if (name) {
|
||||
const logger = new Logger('getSectorName');
|
||||
|
||||
logger.warn(`Could not map the sector "${name}" to the ontology`);
|
||||
}
|
||||
|
||||
return 'Other';
|
||||
}
|
||||
@ -0,0 +1,3 @@
|
||||
import type { SECTORS } from '../config';
|
||||
|
||||
export type SectorName = (typeof SECTORS)[number];
|
||||
Loading…
Reference in new issue