Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Reduce of empty array with no initial value #3150

Closed
helgehatt opened this issue Mar 15, 2024 · 0 comments · Fixed by #3446
Closed

[BUG] Reduce of empty array with no initial value #3150

helgehatt opened this issue Mar 15, 2024 · 0 comments · Fixed by #3446
Labels
bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed

Comments

@helgehatt
Copy link
Contributor

Bug Description

Missing handling of empty dateStrings array. Should be a good first issue.

const lastDateString = dateStrings.reduce((a, b) => {
return a > b ? a : b;
});

TypeError: Reduce of empty array with no initial value
    at Array.reduce (<anonymous>)
    at ExchangeRateDataService.getExchangeRatesByCurrency (/home/helge/github/ghostfolio/dist/apps/api/webpack:/src/services/exchange-rate-data/exchange-rate-data.service.ts:79:42)
    at PortfolioCalculator.getCurrentPositions (/home/helge/github/ghostfolio/dist/apps/api/webpack:/src/app/portfolio/portfolio-calculator.ts:534:7)
    at PortfolioService.getPerformance (/home/helge/github/ghostfolio/dist/apps/api/webpack:/src/app/portfolio/portfolio.service.ts:1206:9)
    at PortfolioController.getPerformanceV2 (/home/helge/github/ghostfolio/dist/apps/api/webpack:/src/app/portfolio/portfolio.controller.ts:401:36)

To Reproduce

  1. Import activities in a new foreign currency
  2. Refresh portfolio page before currency data has been fetched
@dtslvr dtslvr added bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed labels Mar 15, 2024
@dtslvr dtslvr linked a pull request Jun 1, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
2 participants