diff --git a/CHANGELOG.md b/CHANGELOG.md index bd4aade28..721281c05 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,10 +7,18 @@ 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 + ### Changed - Set the `lastmod` dates of `sitemap.xml` dynamically +### Fixed + +- Fixed the missing values in the holdings table + ## 1.292.0 - 2023-07-24 ### Added 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..eb35a577f --- /dev/null +++ b/apps/api/src/app/redis-cache/interfaces/redis-store.interface.ts @@ -0,0 +1,8 @@ +import { Store } from 'cache-manager'; +import { RedisClient } from 'redis'; + +export interface RedisStore extends Store { + getClient: () => 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); 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');