From 0a01d4234a947bc4edebbf9f64257fbc2fbbc094 Mon Sep 17 00:00:00 2001 From: Thomas Kaul <4159106+dtslvr@users.noreply.github.com> Date: Fri, 31 Jul 2026 19:50:09 +0200 Subject: [PATCH] Bugfix/daily requests check in Ghostfolio data provider (#7485) Fix daily requests check --- .../ghostfolio/ghostfolio.controller.ts | 12 ++++++------ .../data-providers/ghostfolio/ghostfolio.service.ts | 8 ++++++-- apps/api/src/app/user/user.service.ts | 2 +- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/apps/api/src/app/endpoints/data-providers/ghostfolio/ghostfolio.controller.ts b/apps/api/src/app/endpoints/data-providers/ghostfolio/ghostfolio.controller.ts index 5d6979acc..6e5f48d63 100644 --- a/apps/api/src/app/endpoints/data-providers/ghostfolio/ghostfolio.controller.ts +++ b/apps/api/src/app/endpoints/data-providers/ghostfolio/ghostfolio.controller.ts @@ -51,7 +51,7 @@ export class GhostfolioController { const maxDailyRequests = await this.ghostfolioService.getMaxDailyRequests(); if ( - this.request.user.dataProviderGhostfolioDailyRequests > maxDailyRequests + this.request.user.dataProviderGhostfolioDailyRequests >= maxDailyRequests ) { throw new HttpException( getReasonPhrase(StatusCodes.TOO_MANY_REQUESTS), @@ -95,7 +95,7 @@ export class GhostfolioController { const maxDailyRequests = await this.ghostfolioService.getMaxDailyRequests(); if ( - this.request.user.dataProviderGhostfolioDailyRequests > maxDailyRequests + this.request.user.dataProviderGhostfolioDailyRequests >= maxDailyRequests ) { throw new HttpException( getReasonPhrase(StatusCodes.TOO_MANY_REQUESTS), @@ -135,7 +135,7 @@ export class GhostfolioController { const maxDailyRequests = await this.ghostfolioService.getMaxDailyRequests(); if ( - this.request.user.dataProviderGhostfolioDailyRequests > maxDailyRequests + this.request.user.dataProviderGhostfolioDailyRequests >= maxDailyRequests ) { throw new HttpException( getReasonPhrase(StatusCodes.TOO_MANY_REQUESTS), @@ -176,7 +176,7 @@ export class GhostfolioController { const maxDailyRequests = await this.ghostfolioService.getMaxDailyRequests(); if ( - this.request.user.dataProviderGhostfolioDailyRequests > maxDailyRequests + this.request.user.dataProviderGhostfolioDailyRequests >= maxDailyRequests ) { throw new HttpException( getReasonPhrase(StatusCodes.TOO_MANY_REQUESTS), @@ -215,7 +215,7 @@ export class GhostfolioController { const maxDailyRequests = await this.ghostfolioService.getMaxDailyRequests(); if ( - this.request.user.dataProviderGhostfolioDailyRequests > maxDailyRequests + this.request.user.dataProviderGhostfolioDailyRequests >= maxDailyRequests ) { throw new HttpException( getReasonPhrase(StatusCodes.TOO_MANY_REQUESTS), @@ -252,7 +252,7 @@ export class GhostfolioController { const maxDailyRequests = await this.ghostfolioService.getMaxDailyRequests(); if ( - this.request.user.dataProviderGhostfolioDailyRequests > maxDailyRequests + this.request.user.dataProviderGhostfolioDailyRequests >= maxDailyRequests ) { throw new HttpException( getReasonPhrase(StatusCodes.TOO_MANY_REQUESTS), diff --git a/apps/api/src/app/endpoints/data-providers/ghostfolio/ghostfolio.service.ts b/apps/api/src/app/endpoints/data-providers/ghostfolio/ghostfolio.service.ts index 2c22f0c10..31d20b99e 100644 --- a/apps/api/src/app/endpoints/data-providers/ghostfolio/ghostfolio.service.ts +++ b/apps/api/src/app/endpoints/data-providers/ghostfolio/ghostfolio.service.ts @@ -326,8 +326,12 @@ export class GhostfolioService { } public async incrementDailyRequests({ userId }: { userId: string }) { - await this.prismaService.analytics.update({ - data: { + await this.prismaService.analytics.upsert({ + create: { + dataProviderGhostfolioDailyRequests: 1, + user: { connect: { id: userId } } + }, + update: { dataProviderGhostfolioDailyRequests: { increment: 1 } }, where: { userId } diff --git a/apps/api/src/app/user/user.service.ts b/apps/api/src/app/user/user.service.ts index febc967d2..b706e4702 100644 --- a/apps/api/src/app/user/user.service.ts +++ b/apps/api/src/app/user/user.service.ts @@ -326,7 +326,7 @@ export class UserService { updatedAt, activityCount: analytics?.activityCount, dataProviderGhostfolioDailyRequests: - analytics?.dataProviderGhostfolioDailyRequests + analytics?.dataProviderGhostfolioDailyRequests ?? 0 }; if (user.settings) {