Browse Source

Remove symbol profile relation from activities

pull/7984/head
Thomas Kaul 2 weeks ago
parent
commit
0830a2e814
  1. 19
      apps/api/src/app/activities/activities.controller.ts
  2. 21
      apps/api/src/helper/object.helper.spec.ts
  3. 10
      libs/common/src/lib/config.ts

19
apps/api/src/app/activities/activities.controller.ts

@ -33,10 +33,9 @@ import {
Query, Query,
UseInterceptors UseInterceptors
} from '@nestjs/common'; } from '@nestjs/common';
import { Order, Prisma } from '@prisma/client'; import { Order, SymbolProfile } from '@prisma/client';
import { parseISO } from 'date-fns'; import { parseISO } from 'date-fns';
import { StatusCodes, getReasonPhrase } from 'http-status-codes'; import { StatusCodes, getReasonPhrase } from 'http-status-codes';
import { omit } from 'lodash-es';
import { ActivitiesFilterDto } from './activities-filter.dto'; import { ActivitiesFilterDto } from './activities-filter.dto';
import { ActivitiesService } from './activities.service'; import { ActivitiesService } from './activities.service';
@ -218,7 +217,16 @@ export class ActivitiesController {
userId, userId,
userSubscription userSubscription
}: ImpersonationContext }: ImpersonationContext
): Promise<Prisma.OrderGetPayload<{ include: { SymbolProfile: true } }>> { ): Promise<
Order & {
assetProfile: SymbolProfile;
/**
* @deprecated Use `assetProfile` instead
*/
SymbolProfile: SymbolProfile;
}
> {
// Evaluate the more restrictive subscription of the authenticated user // Evaluate the more restrictive subscription of the authenticated user
// and the owner of the activity // and the owner of the activity
const subscription = const subscription =
@ -304,7 +312,10 @@ export class ActivitiesController {
}); });
} }
return omit(activity, ['SymbolProfile']); return {
...activity,
assetProfile: activity.SymbolProfile
};
} }
@HasPermission(permissions.updateActivity) @HasPermission(permissions.updateActivity)

21
apps/api/src/helper/object.helper.spec.ts

@ -3082,6 +3082,20 @@ describe('redactAttributes', () => {
feeInBaseCurrency: 18.2, feeInBaseCurrency: 18.2,
id: '8c623328-6035-4b5f-b6d5-702cc1c9c56b', id: '8c623328-6035-4b5f-b6d5-702cc1c9c56b',
quantity: 50, quantity: 50,
// The relation of the database is part of the response next to the
// asset profile
SymbolProfile: {
comment: 'Reviewed by the administrator',
name: 'Apple Inc',
scraperConfiguration: {
headers: { Authorization: 'Bearer TOKEN' },
mode: 'lazy',
selector: '.price',
url: 'https://example.org/get_price'
},
symbol: 'AAPL',
symbolMapping: { YAHOO: 'AAPL' }
},
type: 'BUY', type: 'BUY',
unitPrice: 220.79, unitPrice: 220.79,
value: 11039.5, value: 11039.5,
@ -3111,6 +3125,13 @@ describe('redactAttributes', () => {
feeInBaseCurrency: null, feeInBaseCurrency: null,
id: '8c623328-6035-4b5f-b6d5-702cc1c9c56b', id: '8c623328-6035-4b5f-b6d5-702cc1c9c56b',
quantity: null, quantity: null,
SymbolProfile: {
comment: null,
name: 'Apple Inc',
scraperConfiguration: null,
symbol: 'AAPL',
symbolMapping: null
},
type: 'BUY', type: 'BUY',
// A price per unit stays visible, like the average price and the market // A price per unit stays visible, like the average price and the market
// price of a holding // price of a holding

10
libs/common/src/lib/config.ts

@ -180,6 +180,16 @@ export const DEFAULT_REDACTED_PATHS = [
'settings.emergencyFund', 'settings.emergencyFund',
'settings.projectedTotalAmount', 'settings.projectedTotalAmount',
'settings.savingsRate', 'settings.savingsRate',
/* @deprecated */
'SymbolProfile.comment',
/* @deprecated */
'SymbolProfile.scraperConfiguration',
/* @deprecated */
'SymbolProfile.symbolMapping',
'totalBalanceInBaseCurrency', 'totalBalanceInBaseCurrency',
'totalDividendInBaseCurrency', 'totalDividendInBaseCurrency',
'totalInterestInBaseCurrency', 'totalInterestInBaseCurrency',

Loading…
Cancel
Save