From 5fe07cb85f1e6552e537ab626f9f09a141874ad2 Mon Sep 17 00:00:00 2001 From: Thomas Kaul <4159106+dtslvr@users.noreply.github.com> Date: Wed, 26 Jul 2023 20:05:26 +0200 Subject: [PATCH 1/3] Bugfix/fix value in holdings table (#2182) * Fix missing value * Update changelog --- CHANGELOG.md | 6 ++++++ .../ui/src/lib/holdings-table/holdings-table.component.html | 4 ++-- libs/ui/src/lib/holdings-table/holdings-table.component.ts | 2 +- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1be362416..a98558fc9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,12 @@ 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). +## Unreleased + +### Fixed + +- Fixed the missing values in the holdings table + ## 1.292.0 - 2023-07-24 ### Added diff --git a/libs/ui/src/lib/holdings-table/holdings-table.component.html b/libs/ui/src/lib/holdings-table/holdings-table.component.html index 5be58e663..29e3eeb1f 100644 --- a/libs/ui/src/lib/holdings-table/holdings-table.component.html +++ b/libs/ui/src/lib/holdings-table/holdings-table.component.html @@ -61,7 +61,7 @@ - + diff --git a/libs/ui/src/lib/holdings-table/holdings-table.component.ts b/libs/ui/src/lib/holdings-table/holdings-table.component.ts index a4aee7710..e11cf69d4 100644 --- a/libs/ui/src/lib/holdings-table/holdings-table.component.ts +++ b/libs/ui/src/lib/holdings-table/holdings-table.component.ts @@ -55,7 +55,7 @@ export class HoldingsTableComponent implements OnChanges, OnDestroy, OnInit { this.displayedColumns = ['icon', 'nameWithSymbol', 'dateOfFirstActivity']; if (this.hasPermissionToShowValues) { - this.displayedColumns.push('value'); + this.displayedColumns.push('valueInBaseCurrency'); } this.displayedColumns.push('allocationInPercentage'); From d9ced885e12ded1758ee19f569ee95c4a7657f2e Mon Sep 17 00:00:00 2001 From: Thomas Kaul <4159106+dtslvr@users.noreply.github.com> Date: Wed, 26 Jul 2023 20:30:32 +0200 Subject: [PATCH 2/3] Feature/add error handling for redis connections (#2179) * Add error handling * Update changelog --- CHANGELOG.md | 4 ++++ .../interfaces/redis-cache.interface.ts | 7 +++++++ .../interfaces/redis-store.interface.ts | 8 ++++++++ .../src/app/redis-cache/redis-cache.service.ts | 15 +++++++++++---- 4 files changed, 30 insertions(+), 4 deletions(-) create mode 100644 apps/api/src/app/redis-cache/interfaces/redis-cache.interface.ts create mode 100644 apps/api/src/app/redis-cache/interfaces/redis-store.interface.ts diff --git a/CHANGELOG.md b/CHANGELOG.md index a98558fc9..60dd52304 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 ## Unreleased +### Added + +- Added error handling for the _Redis_ connections to keep the app running if the connection fails + ### Fixed - Fixed the missing values in the holdings table diff --git a/apps/api/src/app/redis-cache/interfaces/redis-cache.interface.ts b/apps/api/src/app/redis-cache/interfaces/redis-cache.interface.ts new file mode 100644 index 000000000..194da0bc8 --- /dev/null +++ b/apps/api/src/app/redis-cache/interfaces/redis-cache.interface.ts @@ -0,0 +1,7 @@ +import { Cache } from 'cache-manager'; + +import type { RedisStore } from './redis-store.interface'; + +export interface RedisCache extends Cache { + store: RedisStore; +} diff --git a/apps/api/src/app/redis-cache/interfaces/redis-store.interface.ts b/apps/api/src/app/redis-cache/interfaces/redis-store.interface.ts new file mode 100644 index 000000000..83c20eeb0 --- /dev/null +++ b/apps/api/src/app/redis-cache/interfaces/redis-store.interface.ts @@ -0,0 +1,8 @@ +import { Store } from 'cache-manager'; +import Redis from 'redis'; + +export interface RedisStore extends Store { + getClient: () => Redis.RedisClient; + isCacheableValue: (value: any) => boolean; + name: 'redis'; +} diff --git a/apps/api/src/app/redis-cache/redis-cache.service.ts b/apps/api/src/app/redis-cache/redis-cache.service.ts index fb75460ed..865a23aea 100644 --- a/apps/api/src/app/redis-cache/redis-cache.service.ts +++ b/apps/api/src/app/redis-cache/redis-cache.service.ts @@ -1,14 +1,21 @@ import { ConfigurationService } from '@ghostfolio/api/services/configuration/configuration.service'; import { UniqueAsset } from '@ghostfolio/common/interfaces'; -import { CACHE_MANAGER, Inject, Injectable } from '@nestjs/common'; -import { Cache } from 'cache-manager'; +import { CACHE_MANAGER, Inject, Injectable, Logger } from '@nestjs/common'; + +import type { RedisCache } from './interfaces/redis-cache.interface'; @Injectable() export class RedisCacheService { public constructor( - @Inject(CACHE_MANAGER) private readonly cache: Cache, + @Inject(CACHE_MANAGER) private readonly cache: RedisCache, private readonly configurationService: ConfigurationService - ) {} + ) { + const client = cache.store.getClient(); + + client.on('error', (error) => { + Logger.error(error, 'RedisCacheService'); + }); + } public async get(key: string): Promise { return await this.cache.get(key); From efd9e7a5c78916285ed8a5ea63c28b5a33c3b81f Mon Sep 17 00:00:00 2001 From: Thomas Kaul <4159106+dtslvr@users.noreply.github.com> Date: Wed, 26 Jul 2023 20:36:34 +0200 Subject: [PATCH 3/3] Fix RedisClient import (#2183) --- .../src/app/redis-cache/interfaces/redis-store.interface.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/api/src/app/redis-cache/interfaces/redis-store.interface.ts b/apps/api/src/app/redis-cache/interfaces/redis-store.interface.ts index 83c20eeb0..eb35a577f 100644 --- a/apps/api/src/app/redis-cache/interfaces/redis-store.interface.ts +++ b/apps/api/src/app/redis-cache/interfaces/redis-store.interface.ts @@ -1,8 +1,8 @@ import { Store } from 'cache-manager'; -import Redis from 'redis'; +import { RedisClient } from 'redis'; export interface RedisStore extends Store { - getClient: () => Redis.RedisClient; + getClient: () => RedisClient; isCacheableValue: (value: any) => boolean; name: 'redis'; }