From 88782124872f8257c5e62d6f607f70c71ce7f252 Mon Sep 17 00:00:00 2001 From: Thomas Kaul <4159106+dtslvr@users.noreply.github.com> Date: Mon, 3 Feb 2025 15:23:37 +0100 Subject: [PATCH] Feature/expire snapshot cache on holding tags change (#4277) * Expire snapshot cache on holding tags change * Update changelog --- CHANGELOG.md | 1 + apps/api/src/app/order/order.service.ts | 13 ++++++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c531a7c75..ea3614b22 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed +- Improved the caching of the portfolio snapshot in the portfolio calculator by expiring cache entries when a user changes tags in the holding detail dialog - Improved the language localization for German (`de`) ## 2.137.1 - 2025-02-01 diff --git a/apps/api/src/app/order/order.service.ts b/apps/api/src/app/order/order.service.ts index e80811351..a26099e9d 100644 --- a/apps/api/src/app/order/order.service.ts +++ b/apps/api/src/app/order/order.service.ts @@ -63,14 +63,14 @@ export class OrderService { } }); - return Promise.all( + await Promise.all( orders.map(({ id }) => this.prismaService.order.update({ data: { tags: { // The set operation replaces all existing connections with the provided ones - set: tags.map(({ id }) => { - return { id }; + set: tags.map((tag) => { + return { id: tag.id }; }) } }, @@ -78,6 +78,13 @@ export class OrderService { }) ) ); + + this.eventEmitter.emit( + PortfolioChangedEvent.getName(), + new PortfolioChangedEvent({ + userId + }) + ); } public async createOrder(