From 72663fe40a1fa67a015c035c907b1456d5bf8689 Mon Sep 17 00:00:00 2001 From: Thomas Kaul <4159106+dtslvr@users.noreply.github.com> Date: Tue, 21 Jul 2026 21:10:37 +0200 Subject: [PATCH 1/2] Task/refactor isAfter() with isFuture() and isPast() (#7389) Refactor isAfter() with isFuture() and isPast() --- .../src/app/portfolio/calculator/portfolio-calculator.ts | 6 ++++-- apps/api/src/services/benchmark/benchmark.service.ts | 4 ++-- .../investment-chart/investment-chart.component.ts | 4 ++-- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/apps/api/src/app/portfolio/calculator/portfolio-calculator.ts b/apps/api/src/app/portfolio/calculator/portfolio-calculator.ts index cee94f0208..c1e795c4af 100644 --- a/apps/api/src/app/portfolio/calculator/portfolio-calculator.ts +++ b/apps/api/src/app/portfolio/calculator/portfolio-calculator.ts @@ -51,6 +51,8 @@ import { format, isAfter, isBefore, + isFuture, + isPast, isWithinInterval, min, startOfDay, @@ -134,7 +136,7 @@ export abstract class PortfolioCalculator { dateOfFirstActivity = date; } - if (isAfter(date, new Date())) { + if (isFuture(date)) { // Adapt date to today if activity is in future (e.g. liability) // to include it in the interval date = endOfDay(new Date()); @@ -1113,7 +1115,7 @@ export abstract class PortfolioCalculator { portfolioSnapshot ); - if (isAfter(new Date(), new Date(expiration))) { + if (isPast(new Date(expiration))) { isCachedPortfolioSnapshotExpired = true; } } catch {} diff --git a/apps/api/src/services/benchmark/benchmark.service.ts b/apps/api/src/services/benchmark/benchmark.service.ts index 99ceaf21ef..affb0da08f 100644 --- a/apps/api/src/services/benchmark/benchmark.service.ts +++ b/apps/api/src/services/benchmark/benchmark.service.ts @@ -23,7 +23,7 @@ import { BenchmarkTrend } from '@ghostfolio/common/types'; import { Injectable, Logger } from '@nestjs/common'; import { SymbolProfile } from '@prisma/client'; import { Big } from 'big.js'; -import { addHours, isAfter, subDays } from 'date-fns'; +import { addHours, isPast, subDays } from 'date-fns'; import { round, uniqBy } from 'lodash'; import ms from 'ms'; @@ -94,7 +94,7 @@ export class BenchmarkService { this.logger.debug('Fetched benchmarks from cache'); - if (isAfter(new Date(), new Date(expiration))) { + if (isPast(new Date(expiration))) { this.calculateAndCacheBenchmarks({ enableSharing }); diff --git a/apps/client/src/app/components/investment-chart/investment-chart.component.ts b/apps/client/src/app/components/investment-chart/investment-chart.component.ts index dc3152f120..3aa65b9983 100644 --- a/apps/client/src/app/components/investment-chart/investment-chart.component.ts +++ b/apps/client/src/app/components/investment-chart/investment-chart.component.ts @@ -41,7 +41,7 @@ import { } from 'chart.js'; import 'chartjs-adapter-date-fns'; import { type AnnotationOptions } from 'chartjs-plugin-annotation'; -import { isAfter } from 'date-fns'; +import { isFuture } from 'date-fns'; import { NgxSkeletonLoaderModule } from 'ngx-skeleton-loader'; @Component({ @@ -311,6 +311,6 @@ export class GfInvestmentChartComponent implements OnChanges, OnDestroy { return undefined; } - return isAfter(new Date(xValue), new Date()) ? aValue : undefined; + return isFuture(new Date(xValue)) ? aValue : undefined; } } From a20d394e0b2c8a10ad530f5de5860142d6d0d8c4 Mon Sep 17 00:00:00 2001 From: Thomas Kaul <4159106+dtslvr@users.noreply.github.com> Date: Wed, 22 Jul 2026 17:03:13 +0200 Subject: [PATCH 2/2] Bugfix/improve error handling in access endpoints (#7392) * Improve error handling * Update changelog --- CHANGELOG.md | 6 ++++++ apps/api/src/app/access/access.controller.ts | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ac4ba04b5f..3665b66adc 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 + +- Improved the error handling in the access endpoints (`POST` and `PUT`) to return `400 Bad Request` when granting access to a non-existent user + ## 3.31.0 - 2026-07-20 ### Changed diff --git a/apps/api/src/app/access/access.controller.ts b/apps/api/src/app/access/access.controller.ts index 35b1d485b0..d692f358df 100644 --- a/apps/api/src/app/access/access.controller.ts +++ b/apps/api/src/app/access/access.controller.ts @@ -87,7 +87,7 @@ export class AccessController { } try { - return this.accessService.createAccess({ + return await this.accessService.createAccess({ alias: data.alias || undefined, granteeUser: data.granteeUserId ? { connect: { id: data.granteeUserId } } @@ -155,7 +155,7 @@ export class AccessController { } try { - return this.accessService.updateAccess({ + return await this.accessService.updateAccess({ data: { alias: data.alias, granteeUser: data.granteeUserId