Browse Source
Feature/remove activities import limit for premium users (#1082)
* Remove activities import limit for premium users
* Update changelog
pull/1084/head
Thomas Kaul
3 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with
31 additions and
12 deletions
-
CHANGELOG.md
-
apps/api/src/app/import/import.controller.ts
-
apps/api/src/app/import/import.service.ts
-
apps/api/src/services/configuration.service.ts
-
apps/api/src/services/interfaces/environment.interface.ts
-
apps/client/src/app/pages/portfolio/transactions/import-transaction-dialog/import-transaction-dialog.html
|
|
@ -10,6 +10,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 |
|
|
|
### Changed |
|
|
|
|
|
|
|
- Removed the alias from the user interface as a preparation to remove it from the `User` database schema |
|
|
|
- Removed the activities import limit for users with a subscription |
|
|
|
|
|
|
|
### Todo |
|
|
|
|
|
|
|
- Rename the environment variable from `MAX_ORDERS_TO_IMPORT` to `MAX_ACTIVITIES_TO_IMPORT` |
|
|
|
|
|
|
|
## 1.169.0 - 14.07.2022 |
|
|
|
|
|
|
|
|
|
@ -34,8 +34,20 @@ export class ImportController { |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
let maxActivitiesToImport = this.configurationService.get( |
|
|
|
'MAX_ACTIVITIES_TO_IMPORT' |
|
|
|
); |
|
|
|
|
|
|
|
if ( |
|
|
|
this.configurationService.get('ENABLE_FEATURE_SUBSCRIPTION') && |
|
|
|
this.request.user.subscription.type === 'Premium' |
|
|
|
) { |
|
|
|
maxActivitiesToImport = Number.MAX_SAFE_INTEGER; |
|
|
|
} |
|
|
|
|
|
|
|
try { |
|
|
|
return await this.importService.import({ |
|
|
|
maxActivitiesToImport, |
|
|
|
activities: importData.activities, |
|
|
|
userId: this.request.user.id |
|
|
|
}); |
|
|
|
|
|
@ -17,9 +17,11 @@ export class ImportService { |
|
|
|
|
|
|
|
public async import({ |
|
|
|
activities, |
|
|
|
maxActivitiesToImport, |
|
|
|
userId |
|
|
|
}: { |
|
|
|
activities: Partial<CreateOrderDto>[]; |
|
|
|
maxActivitiesToImport: number; |
|
|
|
userId: string; |
|
|
|
}): Promise<void> { |
|
|
|
for (const activity of activities) { |
|
|
@ -32,7 +34,11 @@ export class ImportService { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
await this.validateActivities({ activities, userId }); |
|
|
|
await this.validateActivities({ |
|
|
|
activities, |
|
|
|
maxActivitiesToImport, |
|
|
|
userId |
|
|
|
}); |
|
|
|
|
|
|
|
const accountIds = (await this.accountService.getAccounts(userId)).map( |
|
|
|
(account) => { |
|
|
@ -81,19 +87,15 @@ export class ImportService { |
|
|
|
|
|
|
|
private async validateActivities({ |
|
|
|
activities, |
|
|
|
maxActivitiesToImport, |
|
|
|
userId |
|
|
|
}: { |
|
|
|
activities: Partial<CreateOrderDto>[]; |
|
|
|
maxActivitiesToImport: number; |
|
|
|
userId: string; |
|
|
|
}) { |
|
|
|
if ( |
|
|
|
activities?.length > this.configurationService.get('MAX_ORDERS_TO_IMPORT') |
|
|
|
) { |
|
|
|
throw new Error( |
|
|
|
`Too many activities (${this.configurationService.get( |
|
|
|
'MAX_ORDERS_TO_IMPORT' |
|
|
|
)} at most)` |
|
|
|
); |
|
|
|
if (activities?.length > maxActivitiesToImport) { |
|
|
|
throw new Error(`Too many activities (${maxActivitiesToImport} at most)`); |
|
|
|
} |
|
|
|
|
|
|
|
const existingActivities = await this.orderService.orders({ |
|
|
|
|
|
@ -33,8 +33,8 @@ export class ConfigurationService { |
|
|
|
GOOGLE_SHEETS_PRIVATE_KEY: str({ default: '' }), |
|
|
|
HOST: host({ default: '0.0.0.0' }), |
|
|
|
JWT_SECRET_KEY: str({}), |
|
|
|
MAX_ACTIVITIES_TO_IMPORT: num({ default: Number.MAX_SAFE_INTEGER }), |
|
|
|
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: host({ default: 'localhost' }), |
|
|
|
|
|
@ -23,8 +23,8 @@ export interface Environment extends CleanedEnvAccessors { |
|
|
|
GOOGLE_SHEETS_ID: string; |
|
|
|
GOOGLE_SHEETS_PRIVATE_KEY: string; |
|
|
|
JWT_SECRET_KEY: string; |
|
|
|
MAX_ACTIVITIES_TO_IMPORT: number; |
|
|
|
MAX_ITEM_IN_CACHE: number; |
|
|
|
MAX_ORDERS_TO_IMPORT: number; |
|
|
|
PORT: number; |
|
|
|
RAKUTEN_RAPID_API_KEY: string; |
|
|
|
REDIS_HOST: string; |
|
|
|
|
|
@ -1,6 +1,6 @@ |
|
|
|
<gf-dialog-header |
|
|
|
mat-dialog-title |
|
|
|
title="Import Transactions Error" |
|
|
|
title="Import Activities Error" |
|
|
|
[deviceType]="data.deviceType" |
|
|
|
(closeButtonClicked)="onCancel()" |
|
|
|
></gf-dialog-header> |
|
|
|