Browse Source

Task/select required symbol profile fields in activities (#7998)

* Select required symbol profile fields

* Remove symbol profile relation from activities

* Update changelog
pull/8020/head
Thomas Kaul 5 days ago
committed by GitHub
parent
commit
9c1e014190
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 1
      CHANGELOG.md
  2. 12
      apps/api/src/app/activities/activities.service.ts
  3. 2
      apps/api/src/app/import/import.service.ts
  4. 85
      apps/api/src/helper/object.helper.spec.ts
  5. 2
      apps/api/src/interceptors/transform-data-source-in-response/transform-data-source-in-response.interceptor.ts
  6. 3
      libs/common/src/lib/config.ts

1
CHANGELOG.md

@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Improved the label of the cash positions in the holdings charts and table
- Excluded the cash position in the base currency from the holdings table on the overview tab of the home page (experimental)
- Extended the tools to get the activities, the portfolio and the watchlist in the server of the Model Context Protocol (MCP) to include the data source (experimental)
- Removed the deprecated `SymbolProfile` field from the endpoints `GET api/v1/activities`, `GET api/v1/activities/:id` and `POST api/v1/import`
- Upgraded `@openrouter/ai-sdk-provider` from version `3.0.0` to `3.1.0`
- Upgraded `ai` from version `7.0.37` to `7.0.114`
- Upgraded `dotenv` from version `17.4.2` to `18.0.3`

12
apps/api/src/app/activities/activities.service.ts

@ -60,7 +60,7 @@ import {
Type as ActivityType
} from '@prisma/client';
import { Big } from 'big.js';
import { groupBy, uniqBy } from 'lodash-es';
import { groupBy, omit, uniqBy } from 'lodash-es';
import { randomUUID } from 'node:crypto';
@Injectable()
@ -655,7 +655,13 @@ export class ActivitiesService {
}
},
// eslint-disable-next-line @typescript-eslint/naming-convention
SymbolProfile: true,
SymbolProfile: {
select: {
currency: true,
dataSource: true,
symbol: true
}
},
tags: true
},
orderBy: [...orderBy, { id: sortDirection }]
@ -736,7 +742,7 @@ export class ActivitiesService {
]);
return {
...order,
...omit(order, ['SymbolProfile']),
assetProfile,
feeInAssetProfileCurrency,
feeInBaseCurrency,

2
apps/api/src/app/import/import.service.ts

@ -1004,7 +1004,7 @@ export class ImportService {
)) ?? 0;
activities.push({
...order,
...omit(order, ['SymbolProfile']),
// @ts-ignore
assetProfile,
error,

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

@ -3082,20 +3082,6 @@ 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,
@ -3125,6 +3111,49 @@ describe('redactAttributes', () => {
feeInBaseCurrency: null,
id: '8c623328-6035-4b5f-b6d5-702cc1c9c56b',
quantity: null,
type: 'BUY',
// A price per unit stays visible, like the average price and the market
// price of a holding
unitPrice: 220.79,
value: null,
valueInBaseCurrency: null
});
});
// The endpoint POST api/v1/activities returns a row of the database with the
// relation to the symbol profile
it('should redact an activity with the relation to the symbol profile', () => {
expect(
redactPaths({
object: {
comment: 'Bought on a dip',
currency: 'USD',
fee: 19.9,
id: '8c623328-6035-4b5f-b6d5-702cc1c9c56b',
quantity: 50,
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
},
paths: DEFAULT_REDACTED_PATHS
})
).toStrictEqual({
comment: null,
currency: 'USD',
fee: null,
id: '8c623328-6035-4b5f-b6d5-702cc1c9c56b',
quantity: null,
SymbolProfile: {
comment: null,
name: 'Apple Inc',
@ -3133,15 +3162,12 @@ describe('redactAttributes', () => {
symbolMapping: null
},
type: 'BUY',
// A price per unit stays visible, like the average price and the market
// price of a holding
unitPrice: 220.79,
value: null,
valueInBaseCurrency: null
unitPrice: 220.79
});
});
// The write endpoints return a row of the database, which has no relation
// The endpoints PUT and DELETE api/v1/activities/:id return a row of the
// database without the relations
it('should redact an activity without the relations', () => {
expect(
redactPaths({
@ -3190,18 +3216,6 @@ describe('redactAttributes', () => {
currency: 'USD',
fee: 19.9,
quantity: 50,
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,
@ -3227,13 +3241,6 @@ describe('redactAttributes', () => {
currency: 'USD',
fee: null,
quantity: null,
SymbolProfile: {
comment: null,
name: 'Apple Inc',
scraperConfiguration: null,
symbol: 'AAPL',
symbolMapping: null
},
type: 'BUY',
unitPrice: 220.79,
value: null,

2
apps/api/src/interceptors/transform-data-source-in-response/transform-data-source-in-response.interceptor.ts

@ -84,7 +84,6 @@ export class TransformDataSourceInResponseInterceptor<
'["filters.dataSource"]',
'activities[*].assetProfile.dataSource',
'activities[*].dataSource',
'activities[*].SymbolProfile.dataSource',
'assetProfile.dataSource',
'benchmarks[*].dataSource',
'errors[*].dataSource',
@ -95,7 +94,6 @@ export class TransformDataSourceInResponseInterceptor<
'items[*].dataSource',
'latestActivities[*].assetProfile.dataSource',
'settings["filters.dataSource"]',
'SymbolProfile.dataSource',
'watchlist[*].dataSource'
]
});

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

@ -138,9 +138,6 @@ export const DEFAULT_REDACTED_PATHS = [
'activities[*].feeInAssetProfileCurrency',
'activities[*].feeInBaseCurrency',
'activities[*].quantity',
'activities[*].SymbolProfile.comment',
'activities[*].SymbolProfile.scraperConfiguration',
'activities[*].SymbolProfile.symbolMapping',
'activities[*].value',
'activities[*].valueInBaseCurrency',
'assetProfile.comment',

Loading…
Cancel
Save