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,
UseInterceptors
} from '@nestjs/common';
import { Order, Prisma } from '@prisma/client';
import { Order, SymbolProfile } from '@prisma/client';
import { parseISO } from 'date-fns';
import { StatusCodes, getReasonPhrase } from 'http-status-codes';
import { omit } from 'lodash-es';
import { ActivitiesFilterDto } from './activities-filter.dto';
import { ActivitiesService } from './activities.service';
@ -218,7 +217,16 @@ export class ActivitiesController {
userId,
userSubscription
}: 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
// and the owner of the activity
const subscription =
@ -304,7 +312,10 @@ export class ActivitiesController {
});
}
return omit(activity, ['SymbolProfile']);
return {
...activity,
assetProfile: activity.SymbolProfile
};
}
@HasPermission(permissions.updateActivity)

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

@ -3082,6 +3082,20 @@ describe('redactAttributes', () => {
feeInBaseCurrency: 18.2,
id: '8c623328-6035-4b5f-b6d5-702cc1c9c56b',
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',
unitPrice: 220.79,
value: 11039.5,
@ -3111,6 +3125,13 @@ describe('redactAttributes', () => {
feeInBaseCurrency: null,
id: '8c623328-6035-4b5f-b6d5-702cc1c9c56b',
quantity: null,
SymbolProfile: {
comment: null,
name: 'Apple Inc',
scraperConfiguration: null,
symbol: 'AAPL',
symbolMapping: null
},
type: 'BUY',
// A price per unit stays visible, like the average price and the market
// price of a holding

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

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

Loading…
Cancel
Save