Browse Source
Feature/replace lodash.uniq with Array.from + Set (#4387)
* Replace lodash.uniq with Array.from + Set
* Update chagnelog
pull/4450/merge
Szymon Łągiewka
15 hours ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with
20 additions and
17 deletions
-
CHANGELOG.md
-
apps/api/src/app/portfolio/calculator/portfolio-calculator.ts
-
apps/api/src/app/portfolio/portfolio.service.ts
-
apps/api/src/services/exchange-rate-data/exchange-rate-data.service.ts
-
apps/client/src/app/components/admin-market-data/create-asset-profile-dialog/create-asset-profile-dialog.component.ts
-
apps/client/src/app/components/user-account-settings/user-account-settings.component.ts
|
|
@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 |
|
|
|
### Changed |
|
|
|
|
|
|
|
- Improved the symbol validation in the _Yahoo Finance_ service (get asset profiles) |
|
|
|
- Refactored `lodash.uniq` with `Array.from(new Set(...))` |
|
|
|
- Refreshed the cryptocurrencies list |
|
|
|
|
|
|
|
### Fixed |
|
|
|
|
|
@ -49,7 +49,7 @@ import { |
|
|
|
min, |
|
|
|
subDays |
|
|
|
} from 'date-fns'; |
|
|
|
import { isNumber, sortBy, sum, uniq, uniqBy } from 'lodash'; |
|
|
|
import { isNumber, sortBy, sum, uniqBy } from 'lodash'; |
|
|
|
|
|
|
|
export abstract class PortfolioCalculator { |
|
|
|
protected static readonly ENABLE_LOGGING = false; |
|
|
@ -222,7 +222,7 @@ export abstract class PortfolioCalculator { |
|
|
|
|
|
|
|
const exchangeRatesByCurrency = |
|
|
|
await this.exchangeRateDataService.getExchangeRatesByCurrency({ |
|
|
|
currencies: uniq(Object.values(currencies)), |
|
|
|
currencies: Array.from(new Set(Object.values(currencies))), |
|
|
|
endDate: endOfDay(this.endDate), |
|
|
|
startDate: this.startDate, |
|
|
|
targetCurrency: this.currency |
|
|
|
|
|
@ -82,7 +82,7 @@ import { |
|
|
|
parseISO, |
|
|
|
set |
|
|
|
} from 'date-fns'; |
|
|
|
import { isEmpty, uniq } from 'lodash'; |
|
|
|
import { isEmpty } from 'lodash'; |
|
|
|
|
|
|
|
import { PortfolioCalculator } from './calculator/portfolio-calculator'; |
|
|
|
import { |
|
|
@ -2032,14 +2032,16 @@ export class PortfolioService { |
|
|
|
where: { id: filters[0].id } |
|
|
|
}); |
|
|
|
} else { |
|
|
|
const accountIds = uniq( |
|
|
|
activities |
|
|
|
.filter(({ accountId }) => { |
|
|
|
return accountId; |
|
|
|
}) |
|
|
|
.map(({ accountId }) => { |
|
|
|
return accountId; |
|
|
|
}) |
|
|
|
const accountIds = Array.from( |
|
|
|
new Set( |
|
|
|
activities |
|
|
|
.filter(({ accountId }) => { |
|
|
|
return accountId; |
|
|
|
}) |
|
|
|
.map(({ accountId }) => { |
|
|
|
return accountId; |
|
|
|
}) |
|
|
|
) |
|
|
|
); |
|
|
|
|
|
|
|
currentAccounts = await this.accountService.accounts({ |
|
|
|
|
|
@ -23,7 +23,7 @@ import { |
|
|
|
isToday, |
|
|
|
subDays |
|
|
|
} from 'date-fns'; |
|
|
|
import { isNumber, uniq } from 'lodash'; |
|
|
|
import { isNumber } from 'lodash'; |
|
|
|
import ms from 'ms'; |
|
|
|
|
|
|
|
@Injectable() |
|
|
@ -515,7 +515,7 @@ export class ExchangeRateDataService { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return uniq(currencies).filter(Boolean).sort(); |
|
|
|
return Array.from(new Set(currencies)).filter(Boolean).sort(); |
|
|
|
} |
|
|
|
|
|
|
|
private prepareCurrencyPairs(aCurrencies: string[]) { |
|
|
|
|
|
@ -20,7 +20,6 @@ import { |
|
|
|
} from '@angular/forms'; |
|
|
|
import { MatDialogRef } from '@angular/material/dialog'; |
|
|
|
import { isISO4217CurrencyCode } from 'class-validator'; |
|
|
|
import { uniq } from 'lodash'; |
|
|
|
import { Subject, takeUntil } from 'rxjs'; |
|
|
|
|
|
|
|
import { CreateAssetProfileDialogMode } from './interfaces/interfaces'; |
|
|
@ -87,7 +86,9 @@ export class CreateAssetProfileDialog implements OnInit, OnDestroy { |
|
|
|
this.createAssetProfileForm.get('addCurrency').value as string |
|
|
|
).toUpperCase(); |
|
|
|
|
|
|
|
const currencies = uniq([...this.customCurrencies, currency]).sort(); |
|
|
|
const currencies = Array.from( |
|
|
|
new Set([...this.customCurrencies, currency]) |
|
|
|
).sort(); |
|
|
|
|
|
|
|
this.dataService |
|
|
|
.putAdminSetting(PROPERTY_CURRENCIES, { |
|
|
|
|
|
@ -24,7 +24,6 @@ import { FormBuilder, Validators } from '@angular/forms'; |
|
|
|
import { MatSlideToggleChange } from '@angular/material/slide-toggle'; |
|
|
|
import { MatSnackBar } from '@angular/material/snack-bar'; |
|
|
|
import { format, parseISO } from 'date-fns'; |
|
|
|
import { uniq } from 'lodash'; |
|
|
|
import ms from 'ms'; |
|
|
|
import { EMPTY, Subject, throwError } from 'rxjs'; |
|
|
|
import { catchError, takeUntil } from 'rxjs/operators'; |
|
|
@ -108,7 +107,7 @@ export class UserAccountSettingsComponent implements OnDestroy, OnInit { |
|
|
|
); |
|
|
|
|
|
|
|
this.locales.push(this.user.settings.locale); |
|
|
|
this.locales = uniq(this.locales.sort()); |
|
|
|
this.locales = Array.from(new Set(this.locales)).sort(); |
|
|
|
|
|
|
|
this.changeDetectorRef.markForCheck(); |
|
|
|
} |
|
|
|