Skip to content

Commit 755ab15

Browse files
authored
Feature/format name in financial modeling prep service (ghostfolio#4441)
* Format name * Update changelog
1 parent b90e307 commit 755ab15

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1111

1212
- Improved the usability of the user account registration
1313
- Improved the usability of the _Copy AI prompt to clipboard_ actions on the analysis page (experimental)
14+
- Formatted the name in the _Financial Modeling Prep_ service
1415
- Removed the exchange rates from the overview of the admin control panel
1516
- Improved the language localization for German (`de`)
1617
- Upgraded `angular` from version `19.0.5` to `19.2.1`

apps/api/src/services/data-provider/financial-modeling-prep/financial-modeling-prep.service.ts

+17-4
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
IDataProviderHistoricalResponse,
1313
IDataProviderResponse
1414
} from '@ghostfolio/api/services/interfaces/interfaces';
15+
import { REPLACE_NAME_PARTS } from '@ghostfolio/common/config';
1516
import { DATE_FORMAT, parseDate } from '@ghostfolio/common/helper';
1617
import {
1718
DataProviderInfo,
@@ -186,7 +187,7 @@ export class FinancialModelingPrepService implements DataProviderInterface {
186187
response.isin = assetProfile.isin;
187188
}
188189

189-
response.name = assetProfile.companyName;
190+
response.name = this.formatName({ name: assetProfile.companyName });
190191

191192
if (assetProfile.website) {
192193
response.url = assetProfile.website;
@@ -398,7 +399,7 @@ export class FinancialModelingPrepService implements DataProviderInterface {
398399
assetSubClass: undefined, // TODO
399400
dataProviderInfo: this.getDataProviderInfo(),
400401
dataSource: this.getName(),
401-
name: companyName
402+
name: this.formatName({ name: companyName })
402403
};
403404
});
404405
} else {
@@ -414,12 +415,12 @@ export class FinancialModelingPrepService implements DataProviderInterface {
414415
items = result.map(({ currency, name, symbol }) => {
415416
return {
416417
currency,
417-
name,
418418
symbol,
419419
assetClass: undefined, // TODO
420420
assetSubClass: undefined, // TODO
421421
dataProviderInfo: this.getDataProviderInfo(),
422-
dataSource: this.getName()
422+
dataSource: this.getName(),
423+
name: this.formatName({ name })
423424
};
424425
});
425426
}
@@ -438,6 +439,18 @@ export class FinancialModelingPrepService implements DataProviderInterface {
438439
return { items };
439440
}
440441

442+
private formatName({ name }: { name: string }) {
443+
if (name) {
444+
for (const part of REPLACE_NAME_PARTS) {
445+
name = name.replace(part, '');
446+
}
447+
448+
name = name.trim();
449+
}
450+
451+
return name;
452+
}
453+
441454
private getUrl({ version }: { version: number }) {
442455
return `https://financialmodelingprep.com/api/v${version}`;
443456
}

0 commit comments

Comments
 (0)