Browse Source
Feature/remove transactions import limit (#536)
* Remove default transactions import limit
* Update changelog
pull/538/head
Thomas Kaul
3 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with
16 additions and
4 deletions
-
CHANGELOG.md
-
apps/api/src/app/import/import.service.ts
-
apps/api/src/services/configuration.service.ts
-
apps/api/src/services/interfaces/environment.interface.ts
|
|
@ -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 |
|
|
|
|
|
@ -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<Order>[]; |
|
|
|
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({ |
|
|
|
|
|
@ -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' }), |
|
|
|
|
|
@ -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; |
|
|
|