diff --git a/CHANGELOG.md b/CHANGELOG.md index 0b962f1f3..09c8e6e48 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 ## Unreleasd +### Changed + +- Removed the default transactions import limit + ### Fixed - Fixed `/bin/sh: prisma: not found` in docker build diff --git a/apps/api/src/app/import/import.service.ts b/apps/api/src/app/import/import.service.ts index 59df401bd..cf9f6f705 100644 --- a/apps/api/src/app/import/import.service.ts +++ b/apps/api/src/app/import/import.service.ts @@ -1,4 +1,5 @@ import { OrderService } from '@ghostfolio/api/app/order/order.service'; +import { ConfigurationService } from '@ghostfolio/api/services/configuration.service'; import { DataProviderService } from '@ghostfolio/api/services/data-provider/data-provider.service'; import { Injectable } from '@nestjs/common'; import { Order } from '@prisma/client'; @@ -6,9 +7,8 @@ import { isSameDay, parseISO } from 'date-fns'; @Injectable() export class ImportService { - private static MAX_ORDERS_TO_IMPORT = 20; - public constructor( + private readonly configurationService: ConfigurationService, private readonly dataProviderService: DataProviderService, private readonly orderService: OrderService ) {} @@ -59,8 +59,14 @@ export class ImportService { orders: Partial[]; userId: string; }) { - if (orders?.length > ImportService.MAX_ORDERS_TO_IMPORT) { - throw new Error('Too many transactions'); + if ( + orders?.length > this.configurationService.get('MAX_ORDERS_TO_IMPORT') + ) { + throw new Error( + `Too many transactions (${this.configurationService.get( + 'MAX_ORDERS_TO_IMPORT' + )} at most)` + ); } const existingOrders = await this.orderService.orders({ diff --git a/apps/api/src/services/configuration.service.ts b/apps/api/src/services/configuration.service.ts index 1956a6b62..b2d9c65fb 100644 --- a/apps/api/src/services/configuration.service.ts +++ b/apps/api/src/services/configuration.service.ts @@ -27,6 +27,7 @@ export class ConfigurationService { GOOGLE_SECRET: str({ default: 'dummySecret' }), JWT_SECRET_KEY: str({}), MAX_ITEM_IN_CACHE: num({ default: 9999 }), + MAX_ORDERS_TO_IMPORT: num({ default: Number.MAX_SAFE_INTEGER }), PORT: port({ default: 3333 }), RAKUTEN_RAPID_API_KEY: str({ default: '' }), REDIS_HOST: str({ default: 'localhost' }), diff --git a/apps/api/src/services/interfaces/environment.interface.ts b/apps/api/src/services/interfaces/environment.interface.ts index e475d32ec..56f8fe822 100644 --- a/apps/api/src/services/interfaces/environment.interface.ts +++ b/apps/api/src/services/interfaces/environment.interface.ts @@ -18,6 +18,7 @@ export interface Environment extends CleanedEnvAccessors { GOOGLE_SECRET: string; JWT_SECRET_KEY: string; MAX_ITEM_IN_CACHE: number; + MAX_ORDERS_TO_IMPORT: number; PORT: number; RAKUTEN_RAPID_API_KEY: string; REDIS_HOST: string;