From 4505441691610621f9e432ce8142b996e2d48186 Mon Sep 17 00:00:00 2001 From: Cygguu <111180580+Cygguu@users.noreply.github.com> Date: Wed, 28 Aug 2024 20:28:11 +0200 Subject: [PATCH 1/4] Feature/improve language localization for polish (#3691) * Improve language localization for Polish * Update changelog --- CHANGELOG.md | 1 + apps/client/src/locales/messages.pl.xlf | 198 ++++++++++++------------ 2 files changed, 100 insertions(+), 99 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9d28fedda..cbf940063 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Reworked the portfolio calculator - Exposed the log levels as an environment variable (`LOG_LEVELS`) - Exposed the maximum of chart data items as an environment variable (`MAX_CHART_ITEMS`) +- Improved the language localization for Polish (`pl`) ### Fixed diff --git a/apps/client/src/locales/messages.pl.xlf b/apps/client/src/locales/messages.pl.xlf index 27c9f9dc7..c7e54de73 100644 --- a/apps/client/src/locales/messages.pl.xlf +++ b/apps/client/src/locales/messages.pl.xlf @@ -299,7 +299,7 @@ privacy-policy - privacy-policy + polityka-prywatnosci apps/client/src/app/app.component.ts 65 @@ -315,7 +315,7 @@ register - register + zarejestruj apps/client/src/app/app.component.ts 71 @@ -351,7 +351,7 @@ resources - resources + zasoby apps/client/src/app/app.component.ts 72 @@ -403,7 +403,7 @@ You are using the Live Demo. - You are using the Live Demo. + Korzystasz z wersji demonstracyjnej. apps/client/src/app/app.component.html 12 @@ -455,7 +455,7 @@ Resources - Resources + Zasoby apps/client/src/app/app.component.html 61 @@ -475,7 +475,7 @@ About - About + O programie apps/client/src/app/app.component.html 67 @@ -591,7 +591,7 @@ Features - Features + Funkcje apps/client/src/app/app.component.html 76 @@ -619,7 +619,7 @@ License - License + Licencja apps/client/src/app/app.component.html 85 @@ -715,7 +715,7 @@ The risk of loss in trading can be substantial. It is not advisable to invest money you may need in the short term. - The risk of loss in trading can be substantial. It is not advisable to invest money you may need in the short term. + Ryzyko strat na rynku może być znaczne. Nie jest zalecane inwestowanie pieniędzy, które mogą być potrzebne w krótkim okresie. apps/client/src/app/app.component.html 199 @@ -723,7 +723,7 @@ Alias - Alias + Alias apps/client/src/app/components/access-table/access-table.component.html 4 @@ -743,7 +743,7 @@ Type - Type + Typ apps/client/src/app/components/admin-jobs/admin-jobs.html 31 @@ -771,7 +771,7 @@ Revoke - Revoke + Cofnij apps/client/src/app/components/access-table/access-table.component.html 62 @@ -803,7 +803,7 @@ Equity - Equity + Kapitał własny apps/client/src/app/components/account-detail-dialog/account-detail-dialog.html 56 @@ -811,7 +811,7 @@ Activities - Activities + Aktywności apps/client/src/app/components/account-detail-dialog/account-detail-dialog.html 61 @@ -851,7 +851,7 @@ Platform - Platform + Platforma apps/client/src/app/components/account-detail-dialog/account-detail-dialog.html 65 @@ -867,7 +867,7 @@ Transfer Cash Balance - Transfer Cash Balance + Transfer Salda Gotówkowego apps/client/src/app/components/accounts-table/accounts-table.component.html 10 @@ -879,7 +879,7 @@ Name - Name + Nazwa apps/client/src/app/components/accounts-table/accounts-table.component.html 43 @@ -931,7 +931,7 @@ Total - Total + Suma apps/client/src/app/components/accounts-table/accounts-table.component.html 55 @@ -939,7 +939,7 @@ Currency - Currency + Waluta apps/client/src/app/components/accounts-table/accounts-table.component.html 65 @@ -967,7 +967,7 @@ Value - Value + Wartość apps/client/src/app/components/accounts-table/accounts-table.component.html 171 @@ -1099,7 +1099,7 @@ Do you really want to delete this account? - Do you really want to delete this account? + Czy na pewno chcesz usunąć to konto? apps/client/src/app/components/accounts-table/accounts-table.component.ts 110 @@ -1107,7 +1107,7 @@ Asset Profile - Asset Profile + Profil Aktywów apps/client/src/app/components/admin-jobs/admin-jobs.html 35 @@ -1115,7 +1115,7 @@ Historical Market Data - Historical Market Data + Historyczne Dane Rynkowe apps/client/src/app/components/admin-jobs/admin-jobs.html 37 @@ -1123,7 +1123,7 @@ Symbol - Symbol + Symbol apps/client/src/app/components/admin-jobs/admin-jobs.html 44 @@ -1147,7 +1147,7 @@ Data Source - Data Source + Źródło Danych apps/client/src/app/components/admin-jobs/admin-jobs.html 53 @@ -1167,7 +1167,7 @@ Attempts - Attempts + Próby apps/client/src/app/components/admin-jobs/admin-jobs.html 81 @@ -1175,7 +1175,7 @@ Created - Created + Utworzono apps/client/src/app/components/admin-jobs/admin-jobs.html 90 @@ -1183,7 +1183,7 @@ Finished - Finished + Zakończono apps/client/src/app/components/admin-jobs/admin-jobs.html 99 @@ -1191,7 +1191,7 @@ Status - Status + Status apps/client/src/app/components/admin-jobs/admin-jobs.html 108 @@ -1199,7 +1199,7 @@ Delete Jobs - Delete Jobs + Usuń Zadania apps/client/src/app/components/admin-jobs/admin-jobs.html 149 @@ -1207,7 +1207,7 @@ View Data - View Data + Zobacz Dane apps/client/src/app/components/admin-jobs/admin-jobs.html 164 @@ -1215,7 +1215,7 @@ View Stacktrace - View Stacktrace + Wyświetl Stos Wywołań apps/client/src/app/components/admin-jobs/admin-jobs.html 171 @@ -1223,7 +1223,7 @@ Delete Job - Delete Job + Usuń Zadanie apps/client/src/app/components/admin-jobs/admin-jobs.html 177 @@ -1231,7 +1231,7 @@ Details for - Details for + Szczegóły dla apps/client/src/app/components/admin-market-data-detail/market-data-detail-dialog/market-data-detail-dialog.html 2 @@ -1239,7 +1239,7 @@ Date - Date + Data apps/client/src/app/components/admin-market-data-detail/market-data-detail-dialog/market-data-detail-dialog.html 6 @@ -1271,7 +1271,7 @@ Cancel - Cancel + Anuluj apps/client/src/app/components/admin-market-data-detail/market-data-detail-dialog/market-data-detail-dialog.html 46 @@ -1315,7 +1315,7 @@ Save - Save + Zapisz apps/client/src/app/components/admin-market-data-detail/market-data-detail-dialog/market-data-detail-dialog.html 48 @@ -1351,7 +1351,7 @@ Currencies - Currencies + Waluty apps/client/src/app/components/admin-market-data/admin-market-data.component.ts 85 @@ -1359,7 +1359,7 @@ ETFs without Countries - ETFs without Countries + ETF-y bez Krajów apps/client/src/app/components/admin-market-data/admin-market-data.component.ts 90 @@ -1367,7 +1367,7 @@ ETFs without Sectors - ETFs without Sectors + ETF-y bez Sektorów apps/client/src/app/components/admin-market-data/admin-market-data.component.ts 95 @@ -1375,7 +1375,7 @@ Do you really want to delete this asset profile? - Do you really want to delete this asset profile? + Czy na pewno chcesz usunąć ten profil aktywów? apps/client/src/app/components/admin-market-data/admin-market-data.service.ts 33 @@ -1383,7 +1383,7 @@ Filter by... - Filter by... + Filtruj według... apps/client/src/app/components/admin-market-data/admin-market-data.component.ts 328 @@ -1391,7 +1391,7 @@ Asset Class - Asset Class + Klasa Aktywów apps/client/src/app/components/admin-market-data/admin-market-data.html 86 @@ -1415,7 +1415,7 @@ Asset Sub Class - Asset Sub Class + Podklasa Aktywów apps/client/src/app/components/admin-market-data/admin-market-data.html 95 @@ -1439,7 +1439,7 @@ First Activity - First Activity + Pierwsza Aktywność apps/client/src/app/components/admin-market-data/admin-market-data.html 104 @@ -1459,7 +1459,7 @@ Activities Count - Activities Count + Liczba Aktywności apps/client/src/app/components/admin-market-data/admin-market-data.html 113 @@ -1467,7 +1467,7 @@ Historical Data - Historical Data + Dane Historyczne apps/client/src/app/components/admin-market-data/admin-market-data.html 122 @@ -1479,7 +1479,7 @@ Sectors Count - Sectors Count + Liczba Sektorów apps/client/src/app/components/admin-market-data/admin-market-data.html 131 @@ -1487,7 +1487,7 @@ Countries Count - Countries Count + Liczba Krajów apps/client/src/app/components/admin-market-data/admin-market-data.html 140 @@ -1495,7 +1495,7 @@ Gather Recent Data - Gather Recent Data + Zbierz Najnowsze Dane apps/client/src/app/components/admin-market-data/admin-market-data.html 177 @@ -1503,7 +1503,7 @@ Gather All Data - Gather All Data + Zbierz Wszystkie Dane apps/client/src/app/components/admin-market-data/admin-market-data.html 180 @@ -1511,7 +1511,7 @@ Gather Profile Data - Gather Profile Data + Zbierz Dane Profilu apps/client/src/app/components/admin-market-data/admin-market-data.html 183 @@ -1531,7 +1531,7 @@ Refresh - Refresh + Odśwież apps/client/src/app/components/admin-market-data/asset-profile-dialog/asset-profile-dialog.html 22 @@ -1539,7 +1539,7 @@ Gather Historical Data - Gather Historical Data + Zbierz Dane Historyczne apps/client/src/app/components/admin-market-data/asset-profile-dialog/asset-profile-dialog.html 32 @@ -1547,7 +1547,7 @@ Import - Import + Importuj apps/client/src/app/components/admin-market-data/asset-profile-dialog/asset-profile-dialog.html 110 @@ -1563,7 +1563,7 @@ Sector - Sector + Sektor apps/client/src/app/components/admin-market-data/asset-profile-dialog/asset-profile-dialog.html 187 @@ -1575,7 +1575,7 @@ Country - Country + Kraj apps/client/src/app/components/admin-market-data/asset-profile-dialog/asset-profile-dialog.html 198 @@ -1591,7 +1591,7 @@ Sectors - Sectors + Sektory apps/client/src/app/components/admin-market-data/asset-profile-dialog/asset-profile-dialog.html 204 @@ -1611,7 +1611,7 @@ Countries - Countries + Kraje apps/client/src/app/components/admin-market-data/asset-profile-dialog/asset-profile-dialog.html 214 @@ -1627,7 +1627,7 @@ Benchmark - Benchmark + Benchmark apps/client/src/app/components/admin-market-data/asset-profile-dialog/asset-profile-dialog.html 286 @@ -1635,7 +1635,7 @@ Symbol Mapping - Symbol Mapping + Mapowanie Symboli apps/client/src/app/components/admin-market-data/asset-profile-dialog/asset-profile-dialog.html 292 @@ -1643,7 +1643,7 @@ Scraper Configuration - Scraper Configuration + Konfiguracja Scrapera apps/client/src/app/components/admin-market-data/asset-profile-dialog/asset-profile-dialog.html 304 @@ -1651,7 +1651,7 @@ Note - Note + Notatka apps/client/src/app/components/admin-market-data/asset-profile-dialog/asset-profile-dialog.html 365 @@ -1667,7 +1667,7 @@ Add Asset Profile - Add Asset Profile + Dodaj Profil Aktywa apps/client/src/app/components/admin-market-data/create-asset-profile-dialog/create-asset-profile-dialog.html 7 @@ -1675,7 +1675,7 @@ Search - Search + Szukaj apps/client/src/app/components/admin-market-data/create-asset-profile-dialog/create-asset-profile-dialog.html 16 @@ -1683,7 +1683,7 @@ Add Manually - Add Manually + Dodaj Ręcznie apps/client/src/app/components/admin-market-data/create-asset-profile-dialog/create-asset-profile-dialog.html 19 @@ -1691,7 +1691,7 @@ Name, symbol or ISIN - Name, symbol or ISIN + Nazwa, symbol lub ISIN apps/client/src/app/components/admin-market-data/create-asset-profile-dialog/create-asset-profile-dialog.html 26 @@ -1703,7 +1703,7 @@ Please add a currency: - Please add a currency: + Proszę dodać walutę: apps/client/src/app/components/admin-overview/admin-overview.component.ts 125 @@ -1711,7 +1711,7 @@ Do you really want to delete this coupon? - Do you really want to delete this coupon? + Czy naprawdę chcesz usunąć ten kupon? apps/client/src/app/components/admin-overview/admin-overview.component.ts 152 @@ -1719,7 +1719,7 @@ Do you really want to delete this currency? - Do you really want to delete this currency? + Czy naprawdę chcesz usunąć tę walutę? apps/client/src/app/components/admin-overview/admin-overview.component.ts 165 @@ -1727,7 +1727,7 @@ Do you really want to delete this system message? - Do you really want to delete this system message? + Czy naprawdę chcesz usunąć tę wiadomość systemową? apps/client/src/app/components/admin-overview/admin-overview.component.ts 178 @@ -1735,7 +1735,7 @@ Do you really want to flush the cache? - Do you really want to flush the cache? + Czy naprawdę chcesz wyczyścić pamięć podręczną? apps/client/src/app/components/admin-overview/admin-overview.component.ts 202 @@ -1743,7 +1743,7 @@ Please set your system message: - Please set your system message: + Proszę ustawić swoją wiadomość systemową: apps/client/src/app/components/admin-overview/admin-overview.component.ts 222 @@ -1751,7 +1751,7 @@ Version - Version + Wersja apps/client/src/app/components/admin-overview/admin-overview.html 7 @@ -1759,7 +1759,7 @@ User Count - User Count + Liczba Użytkowników apps/client/src/app/components/admin-overview/admin-overview.html 13 @@ -1767,7 +1767,7 @@ Activity Count - Activity Count + Liczba Aktywności apps/client/src/app/components/admin-overview/admin-overview.html 19 @@ -1775,7 +1775,7 @@ per User - per User + na Użytkownika apps/client/src/app/components/admin-overview/admin-overview.html 28 @@ -1783,7 +1783,7 @@ Exchange Rates - Exchange Rates + Kursy Walut apps/client/src/app/components/admin-overview/admin-overview.html 34 @@ -1791,7 +1791,7 @@ Add Currency - Add Currency + Dodaj Walutę apps/client/src/app/components/admin-overview/admin-overview.html 104 @@ -1799,7 +1799,7 @@ User Signup - User Signup + Rejestracja Użytkownika apps/client/src/app/components/admin-overview/admin-overview.html 110 @@ -1807,7 +1807,7 @@ Read-only Mode - Read-only Mode + Tryb Tylko do Odczytu apps/client/src/app/components/admin-overview/admin-overview.html 124 @@ -1815,7 +1815,7 @@ System Message - System Message + Wiadomość Systemowa apps/client/src/app/components/admin-overview/admin-overview.html 148 @@ -1823,7 +1823,7 @@ Set Message - Set Message + Ustaw Wiadomość apps/client/src/app/components/admin-overview/admin-overview.html 170 @@ -1831,7 +1831,7 @@ Coupons - Coupons + Kupony apps/client/src/app/components/admin-overview/admin-overview.html 178 @@ -1839,7 +1839,7 @@ Add - Add + Dodaj apps/client/src/app/components/admin-overview/admin-overview.html 238 @@ -1851,7 +1851,7 @@ Housekeeping - Housekeeping + Konserwacja apps/client/src/app/components/admin-overview/admin-overview.html 246 @@ -1859,7 +1859,7 @@ Flush Cache - Flush Cache + Wyczyszczenie pamięci podręcznej apps/client/src/app/components/admin-overview/admin-overview.html 250 @@ -1867,7 +1867,7 @@ Add Platform - Add Platform + Dodaj Platformę apps/client/src/app/components/admin-platform/admin-platform.component.html 11 @@ -1875,7 +1875,7 @@ Url - Url + Url apps/client/src/app/components/admin-market-data/asset-profile-dialog/asset-profile-dialog.html 352 @@ -1891,7 +1891,7 @@ Accounts - Accounts + Konta apps/client/src/app/components/admin-platform/admin-platform.component.html 65 @@ -1923,7 +1923,7 @@ Do you really want to delete this platform? - Do you really want to delete this platform? + Czy naprawdę chcesz usunąć tę platformę? apps/client/src/app/components/admin-platform/admin-platform.component.ts 86 @@ -1931,7 +1931,7 @@ Update platform - Update platform + Aktualizuj platformę apps/client/src/app/components/admin-platform/create-or-update-platform-dialog/create-or-update-platform-dialog.html 8 @@ -1939,7 +1939,7 @@ Add platform - Add platform + Dodaj platformę apps/client/src/app/components/admin-platform/create-or-update-platform-dialog/create-or-update-platform-dialog.html 10 @@ -1947,7 +1947,7 @@ Platforms - Platforms + Platformy apps/client/src/app/components/admin-settings/admin-settings.component.html 4 @@ -1955,7 +1955,7 @@ Tags - Tags + Tagi apps/client/src/app/components/admin-settings/admin-settings.component.html 10 @@ -1979,7 +1979,7 @@ Add Tag - Add Tag + Dodaj Tag apps/client/src/app/components/admin-tag/admin-tag.component.html 11 @@ -1987,7 +1987,7 @@ Do you really want to delete this tag? - Do you really want to delete this tag? + Czy naprawdę chcesz usunąć ten tag? apps/client/src/app/components/admin-tag/admin-tag.component.ts 86 @@ -1995,7 +1995,7 @@ Update tag - Update tag + Aktualizuj tag apps/client/src/app/components/admin-tag/create-or-update-tag-dialog/create-or-update-tag-dialog.html 8 @@ -2003,7 +2003,7 @@ Add tag - Add tag + Dodaj tag apps/client/src/app/components/admin-tag/create-or-update-tag-dialog/create-or-update-tag-dialog.html 10 From c4a28c6bff7e855603e146a4a6542245bbb67081 Mon Sep 17 00:00:00 2001 From: Thomas Kaul <4159106+dtslvr@users.noreply.github.com> Date: Wed, 28 Aug 2024 20:28:36 +0200 Subject: [PATCH 2/4] Feature/set up a performance logging service (#3703) * Setup performance logging service * Update changelog --- CHANGELOG.md | 4 + .../account-balance.service.ts | 2 + apps/api/src/app/order/order.service.ts | 2 + .../calculator/portfolio-calculator.ts | 12 +-- .../src/app/portfolio/current-rate.service.ts | 2 + .../src/app/portfolio/portfolio.controller.ts | 2 + .../api/src/app/portfolio/portfolio.module.ts | 2 + .../performance-logging.interceptor.ts | 80 +++++++++++++++++++ .../performance-logging.module.ts | 10 +++ .../performance-logging.service.ts | 21 +++++ .../coingecko/coingecko.service.ts | 6 +- .../eod-historical-data.service.ts | 6 +- .../financial-modeling-prep.service.ts | 6 +- .../exchange-rate-data.service.ts | 2 + 14 files changed, 140 insertions(+), 17 deletions(-) create mode 100644 apps/api/src/interceptors/performance-logging/performance-logging.interceptor.ts create mode 100644 apps/api/src/interceptors/performance-logging/performance-logging.module.ts create mode 100644 apps/api/src/interceptors/performance-logging/performance-logging.service.ts diff --git a/CHANGELOG.md b/CHANGELOG.md index cbf940063..44d7f7bf6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## 2.106.0-beta.2 - 2024-08-26 +### Added + +- Set up a performance logging service + ### Changed - Reworked the portfolio calculator diff --git a/apps/api/src/app/account-balance/account-balance.service.ts b/apps/api/src/app/account-balance/account-balance.service.ts index 65393cec8..244b4c684 100644 --- a/apps/api/src/app/account-balance/account-balance.service.ts +++ b/apps/api/src/app/account-balance/account-balance.service.ts @@ -1,4 +1,5 @@ import { PortfolioChangedEvent } from '@ghostfolio/api/events/portfolio-changed.event'; +import { LogPerformance } from '@ghostfolio/api/interceptors/performance-logging/performance-logging.interceptor'; import { ExchangeRateDataService } from '@ghostfolio/api/services/exchange-rate-data/exchange-rate-data.service'; import { PrismaService } from '@ghostfolio/api/services/prisma/prisma.service'; import { resetHours } from '@ghostfolio/common/helper'; @@ -90,6 +91,7 @@ export class AccountBalanceService { return accountBalance; } + @LogPerformance public async getAccountBalances({ filters, user, diff --git a/apps/api/src/app/order/order.service.ts b/apps/api/src/app/order/order.service.ts index f66380e1f..d9ff68d61 100644 --- a/apps/api/src/app/order/order.service.ts +++ b/apps/api/src/app/order/order.service.ts @@ -1,5 +1,6 @@ import { AccountService } from '@ghostfolio/api/app/account/account.service'; import { PortfolioChangedEvent } from '@ghostfolio/api/events/portfolio-changed.event'; +import { LogPerformance } from '@ghostfolio/api/interceptors/performance-logging/performance-logging.interceptor'; import { DataGatheringService } from '@ghostfolio/api/services/data-gathering/data-gathering.service'; import { ExchangeRateDataService } from '@ghostfolio/api/services/exchange-rate-data/exchange-rate-data.service'; import { PrismaService } from '@ghostfolio/api/services/prisma/prisma.service'; @@ -519,6 +520,7 @@ export class OrderService { return { activities, count }; } + @LogPerformance public async getOrdersForPortfolioCalculator({ filters, userCurrency, diff --git a/apps/api/src/app/portfolio/calculator/portfolio-calculator.ts b/apps/api/src/app/portfolio/calculator/portfolio-calculator.ts index 99f71ef0e..0fcb8b9d6 100644 --- a/apps/api/src/app/portfolio/calculator/portfolio-calculator.ts +++ b/apps/api/src/app/portfolio/calculator/portfolio-calculator.ts @@ -5,6 +5,7 @@ import { TransactionPointSymbol } from '@ghostfolio/api/app/portfolio/interfaces import { TransactionPoint } from '@ghostfolio/api/app/portfolio/interfaces/transaction-point.interface'; import { RedisCacheService } from '@ghostfolio/api/app/redis-cache/redis-cache.service'; import { getFactor } from '@ghostfolio/api/helper/portfolio.helper'; +import { LogPerformance } from '@ghostfolio/api/interceptors/performance-logging/performance-logging.interceptor'; import { ConfigurationService } from '@ghostfolio/api/services/configuration/configuration.service'; import { ExchangeRateDataService } from '@ghostfolio/api/services/exchange-rate-data/exchange-rate-data.service'; import { IDataGatheringItem } from '@ghostfolio/api/services/interfaces/interfaces'; @@ -148,6 +149,7 @@ export abstract class PortfolioCalculator { positions: TimelinePosition[] ): PortfolioSnapshot; + @LogPerformance private async computeSnapshot(): Promise { const lastTransactionPoint = last(this.transactionPoints); @@ -861,6 +863,7 @@ export abstract class PortfolioCalculator { return chartDateMap; } + @LogPerformance private computeTransactionPoints() { this.transactionPoints = []; const symbols: { [symbol: string]: TransactionPointSymbol } = {}; @@ -999,6 +1002,7 @@ export abstract class PortfolioCalculator { } } + @LogPerformance private async initialize() { const startTimeTotal = performance.now(); @@ -1033,14 +1037,6 @@ export abstract class PortfolioCalculator { JSON.stringify(this.snapshot), this.configurationService.get('CACHE_QUOTES_TTL') ); - - Logger.debug( - `Computed portfolio snapshot in ${( - (performance.now() - startTimeTotal) / - 1000 - ).toFixed(3)} seconds`, - 'PortfolioCalculator' - ); } } } diff --git a/apps/api/src/app/portfolio/current-rate.service.ts b/apps/api/src/app/portfolio/current-rate.service.ts index 24119162d..cd1994826 100644 --- a/apps/api/src/app/portfolio/current-rate.service.ts +++ b/apps/api/src/app/portfolio/current-rate.service.ts @@ -1,4 +1,5 @@ import { OrderService } from '@ghostfolio/api/app/order/order.service'; +import { LogPerformance } from '@ghostfolio/api/interceptors/performance-logging/performance-logging.interceptor'; import { DataProviderService } from '@ghostfolio/api/services/data-provider/data-provider.service'; import { MarketDataService } from '@ghostfolio/api/services/market-data/market-data.service'; import { resetHours } from '@ghostfolio/common/helper'; @@ -27,6 +28,7 @@ export class CurrentRateService { @Inject(REQUEST) private readonly request: RequestWithUser ) {} + @LogPerformance // TODO: Pass user instead of using this.request.user public async getValues({ dataGatheringItems, diff --git a/apps/api/src/app/portfolio/portfolio.controller.ts b/apps/api/src/app/portfolio/portfolio.controller.ts index 7ce0b0847..036e48901 100644 --- a/apps/api/src/app/portfolio/portfolio.controller.ts +++ b/apps/api/src/app/portfolio/portfolio.controller.ts @@ -7,6 +7,7 @@ import { hasNotDefinedValuesInObject, nullifyValuesInObject } from '@ghostfolio/api/helper/object.helper'; +import { PerformanceLoggingInterceptor } from '@ghostfolio/api/interceptors/performance-logging/performance-logging.interceptor'; import { RedactValuesInResponseInterceptor } from '@ghostfolio/api/interceptors/redact-values-in-response/redact-values-in-response.interceptor'; import { TransformDataSourceInRequestInterceptor } from '@ghostfolio/api/interceptors/transform-data-source-in-request/transform-data-source-in-request.interceptor'; import { TransformDataSourceInResponseInterceptor } from '@ghostfolio/api/interceptors/transform-data-source-in-response/transform-data-source-in-response.interceptor'; @@ -390,6 +391,7 @@ export class PortfolioController { @Get('performance') @UseGuards(AuthGuard('jwt'), HasPermissionGuard) + @UseInterceptors(PerformanceLoggingInterceptor) @UseInterceptors(TransformDataSourceInResponseInterceptor) @Version('2') public async getPerformanceV2( diff --git a/apps/api/src/app/portfolio/portfolio.module.ts b/apps/api/src/app/portfolio/portfolio.module.ts index 7f1f375b1..ad81e9e15 100644 --- a/apps/api/src/app/portfolio/portfolio.module.ts +++ b/apps/api/src/app/portfolio/portfolio.module.ts @@ -4,6 +4,7 @@ import { AccountService } from '@ghostfolio/api/app/account/account.service'; import { OrderModule } from '@ghostfolio/api/app/order/order.module'; import { RedisCacheModule } from '@ghostfolio/api/app/redis-cache/redis-cache.module'; import { UserModule } from '@ghostfolio/api/app/user/user.module'; +import { PerformanceLoggingModule } from '@ghostfolio/api/interceptors/performance-logging/performance-logging.module'; import { RedactValuesInResponseModule } from '@ghostfolio/api/interceptors/redact-values-in-response/redact-values-in-response.module'; import { TransformDataSourceInRequestModule } from '@ghostfolio/api/interceptors/transform-data-source-in-request/transform-data-source-in-request.module'; import { TransformDataSourceInResponseModule } from '@ghostfolio/api/interceptors/transform-data-source-in-response/transform-data-source-in-response.module'; @@ -38,6 +39,7 @@ import { RulesService } from './rules.service'; ImpersonationModule, MarketDataModule, OrderModule, + PerformanceLoggingModule, PrismaModule, RedactValuesInResponseModule, RedisCacheModule, diff --git a/apps/api/src/interceptors/performance-logging/performance-logging.interceptor.ts b/apps/api/src/interceptors/performance-logging/performance-logging.interceptor.ts new file mode 100644 index 000000000..d863f0ec3 --- /dev/null +++ b/apps/api/src/interceptors/performance-logging/performance-logging.interceptor.ts @@ -0,0 +1,80 @@ +import { + Injectable, + NestInterceptor, + ExecutionContext, + CallHandler +} from '@nestjs/common'; +import { Observable } from 'rxjs'; +import { tap } from 'rxjs/operators'; + +import { PerformanceLoggingService } from './performance-logging.service'; + +@Injectable() +export class PerformanceLoggingInterceptor implements NestInterceptor { + public constructor( + private readonly performanceLoggingService: PerformanceLoggingService + ) {} + + public intercept( + context: ExecutionContext, + next: CallHandler + ): Observable { + const startTime = performance.now(); + + const className = context.getClass().name; + const methodName = context.getHandler().name; + + return next.handle().pipe( + tap(() => { + return this.performanceLoggingService.logPerformance({ + className, + methodName, + startTime + }); + }) + ); + } +} + +export function LogPerformance( + target: any, + propertyKey: string, + descriptor: PropertyDescriptor +) { + const originalMethod = descriptor.value; + + descriptor.value = async function (...args: any[]) { + const startTime = performance.now(); + const performanceLoggingService = new PerformanceLoggingService(); + + const result = originalMethod.apply(this, args); + + if (result instanceof Promise) { + // Handle async method + return result + .then((res: any) => { + performanceLoggingService.logPerformance({ + startTime, + className: target.constructor.name, + methodName: propertyKey + }); + + return res; + }) + .catch((error: any) => { + throw error; + }); + } else { + // Handle sync method + performanceLoggingService.logPerformance({ + startTime, + className: target.constructor.name, + methodName: propertyKey + }); + + return result; + } + }; + + return descriptor; +} diff --git a/apps/api/src/interceptors/performance-logging/performance-logging.module.ts b/apps/api/src/interceptors/performance-logging/performance-logging.module.ts new file mode 100644 index 000000000..a26b381e5 --- /dev/null +++ b/apps/api/src/interceptors/performance-logging/performance-logging.module.ts @@ -0,0 +1,10 @@ +import { Module } from '@nestjs/common'; + +import { PerformanceLoggingInterceptor } from './performance-logging.interceptor'; +import { PerformanceLoggingService } from './performance-logging.service'; + +@Module({ + exports: [PerformanceLoggingInterceptor, PerformanceLoggingService], + providers: [PerformanceLoggingInterceptor, PerformanceLoggingService] +}) +export class PerformanceLoggingModule {} diff --git a/apps/api/src/interceptors/performance-logging/performance-logging.service.ts b/apps/api/src/interceptors/performance-logging/performance-logging.service.ts new file mode 100644 index 000000000..1b1faf8e0 --- /dev/null +++ b/apps/api/src/interceptors/performance-logging/performance-logging.service.ts @@ -0,0 +1,21 @@ +import { Injectable, Logger } from '@nestjs/common'; + +@Injectable() +export class PerformanceLoggingService { + public logPerformance({ + className, + methodName, + startTime + }: { + className: string; + methodName: string; + startTime: number; + }) { + const endTime = performance.now(); + + Logger.debug( + `Completed execution of ${methodName}() in ${((endTime - startTime) / 1000).toFixed(3)} seconds`, + className + ); + } +} diff --git a/apps/api/src/services/data-provider/coingecko/coingecko.service.ts b/apps/api/src/services/data-provider/coingecko/coingecko.service.ts index d673dd7aa..067a6fbf9 100644 --- a/apps/api/src/services/data-provider/coingecko/coingecko.service.ts +++ b/apps/api/src/services/data-provider/coingecko/coingecko.service.ts @@ -206,9 +206,9 @@ export class CoinGeckoService implements DataProviderInterface { let message = error; if (error?.code === 'ABORT_ERR') { - message = `RequestError: The operation to get the quotes was aborted because the request to the data provider took more than ${this.configurationService.get( - 'REQUEST_TIMEOUT' - )}ms`; + message = `RequestError: The operation to get the quotes was aborted because the request to the data provider took more than ${( + this.configurationService.get('REQUEST_TIMEOUT') / 1000 + ).toFixed(3)} seconds`; } Logger.error(message, 'CoinGeckoService'); diff --git a/apps/api/src/services/data-provider/eod-historical-data/eod-historical-data.service.ts b/apps/api/src/services/data-provider/eod-historical-data/eod-historical-data.service.ts index 1fe9e0ad1..cf2fd42de 100644 --- a/apps/api/src/services/data-provider/eod-historical-data/eod-historical-data.service.ts +++ b/apps/api/src/services/data-provider/eod-historical-data/eod-historical-data.service.ts @@ -290,9 +290,9 @@ export class EodHistoricalDataService implements DataProviderInterface { let message = error; if (error?.code === 'ABORT_ERR') { - message = `RequestError: The operation to get the quotes was aborted because the request to the data provider took more than ${this.configurationService.get( - 'REQUEST_TIMEOUT' - )}ms`; + message = `RequestError: The operation to get the quotes was aborted because the request to the data provider took more than ${( + this.configurationService.get('REQUEST_TIMEOUT') / 1000 + ).toFixed(3)} seconds`; } Logger.error(message, 'EodHistoricalDataService'); diff --git a/apps/api/src/services/data-provider/financial-modeling-prep/financial-modeling-prep.service.ts b/apps/api/src/services/data-provider/financial-modeling-prep/financial-modeling-prep.service.ts index 2faaf8db8..cf9c5ef9b 100644 --- a/apps/api/src/services/data-provider/financial-modeling-prep/financial-modeling-prep.service.ts +++ b/apps/api/src/services/data-provider/financial-modeling-prep/financial-modeling-prep.service.ts @@ -154,9 +154,9 @@ export class FinancialModelingPrepService implements DataProviderInterface { let message = error; if (error?.code === 'ABORT_ERR') { - message = `RequestError: The operation to get the quotes was aborted because the request to the data provider took more than ${this.configurationService.get( - 'REQUEST_TIMEOUT' - )}ms`; + message = `RequestError: The operation to get the quotes was aborted because the request to the data provider took more than ${( + this.configurationService.get('REQUEST_TIMEOUT') / 1000 + ).toFixed(3)} seconds`; } Logger.error(message, 'FinancialModelingPrepService'); diff --git a/apps/api/src/services/exchange-rate-data/exchange-rate-data.service.ts b/apps/api/src/services/exchange-rate-data/exchange-rate-data.service.ts index 1f08034cd..31b2f885c 100644 --- a/apps/api/src/services/exchange-rate-data/exchange-rate-data.service.ts +++ b/apps/api/src/services/exchange-rate-data/exchange-rate-data.service.ts @@ -1,3 +1,4 @@ +import { LogPerformance } from '@ghostfolio/api/interceptors/performance-logging/performance-logging.interceptor'; import { DataProviderService } from '@ghostfolio/api/services/data-provider/data-provider.service'; import { IDataGatheringItem } from '@ghostfolio/api/services/interfaces/interfaces'; import { MarketDataService } from '@ghostfolio/api/services/market-data/market-data.service'; @@ -46,6 +47,7 @@ export class ExchangeRateDataService { return this.currencyPairs; } + @LogPerformance public async getExchangeRatesByCurrency({ currencies, endDate = new Date(), From 208e5c8adb55b08160365a63f20387bd51da3c4d Mon Sep 17 00:00:00 2001 From: Thomas Kaul <4159106+dtslvr@users.noreply.github.com> Date: Wed, 28 Aug 2024 20:29:59 +0200 Subject: [PATCH 3/4] Release 2.106.0-beta.3 (#3706) --- CHANGELOG.md | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 44d7f7bf6..33705879f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,7 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## 2.106.0-beta.2 - 2024-08-26 +## 2.106.0-beta.3 - 2024-08-28 ### Added diff --git a/package.json b/package.json index dff6da5ce..ef43a39a2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ghostfolio", - "version": "2.106.0-beta.2", + "version": "2.106.0-beta.3", "homepage": "https://ghostfol.io", "license": "AGPL-3.0", "repository": "https://github.com/ghostfolio/ghostfolio", From 7a695f34f2a263b16580e11509302074f3d4ffbe Mon Sep 17 00:00:00 2001 From: Thomas Kaul <4159106+dtslvr@users.noreply.github.com> Date: Thu, 29 Aug 2024 16:13:46 +0200 Subject: [PATCH 4/4] Feature/add docker pulls shield to README.md (#3705) Add Docker Pulls shield --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index d4353351f..365a473ee 100644 --- a/README.md +++ b/README.md @@ -10,8 +10,8 @@ [**Blog**](https://ghostfol.io/en/blog) | [**Slack**](https://join.slack.com/t/ghostfolio/shared_invite/zt-vsaan64h-F_I0fEo5M0P88lP9ibCxFg) | [**X**](https://x.com/ghostfolio_) [![Shield: Buy me a coffee](https://img.shields.io/badge/Buy%20me%20a%20coffee-Support-yellow?logo=buymeacoffee)](https://www.buymeacoffee.com/ghostfolio) -[![Shield: Contributions Welcome](https://img.shields.io/badge/Contributions-Welcome-orange.svg)](#contributing) -[![Shield: License: AGPL v3](https://img.shields.io/badge/License-AGPL%20v3-blue.svg)](https://www.gnu.org/licenses/agpl-3.0) +[![Shield: Contributions Welcome](https://img.shields.io/badge/Contributions-Welcome-limegreen.svg)](#contributing) [![Shield: Docker Pulls](https://img.shields.io/docker/pulls/ghostfolio/ghostfolio?label=Docker%20Pulls)](https://hub.docker.com/r/ghostfolio/ghostfolio) +[![Shield: License: AGPL v3](https://img.shields.io/badge/License-AGPL%20v3-orange.svg)](https://www.gnu.org/licenses/agpl-3.0)