Browse Source
Task/improve performance of deleting watchlist item by loading only required data (#7908)
* Improve performance of deleting watchlist item
* Update changelog
pull/7909/head
Thomas Kaul
1 week ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with
22 additions and
6 deletions
-
CHANGELOG.md
-
apps/api/src/app/endpoints/watchlist/watchlist.controller.ts
-
apps/api/src/app/endpoints/watchlist/watchlist.service.ts
|
|
@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 |
|
|
### Changed |
|
|
### Changed |
|
|
|
|
|
|
|
|
- Localized the default account name created during user registration |
|
|
- Localized the default account name created during user registration |
|
|
|
|
|
- Improved the performance of deleting a watchlist item |
|
|
- Extended the `POST api/v1/user` endpoint by the language code |
|
|
- Extended the `POST api/v1/user` endpoint by the language code |
|
|
- Improved the language localization for German (`de`) |
|
|
- Improved the language localization for German (`de`) |
|
|
- Upgraded `@internationalized/number` from version `3.6.7` to `3.6.8` |
|
|
- Upgraded `@internationalized/number` from version `3.6.7` to `3.6.8` |
|
|
|
|
|
@ -52,14 +52,13 @@ export class WatchlistController { |
|
|
@Param('dataSource') dataSource: DataSource, |
|
|
@Param('dataSource') dataSource: DataSource, |
|
|
@Param('symbol') symbol: string |
|
|
@Param('symbol') symbol: string |
|
|
) { |
|
|
) { |
|
|
const watchlistItems = |
|
|
const hasWatchlistItem = await this.watchlistService.hasWatchlistItem({ |
|
|
await this.watchlistService.getWatchlistItems(userId); |
|
|
dataSource, |
|
|
|
|
|
symbol, |
|
|
const watchlistItem = watchlistItems.find((item) => { |
|
|
userId |
|
|
return item.dataSource === dataSource && item.symbol === symbol; |
|
|
|
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
if (!watchlistItem) { |
|
|
if (!hasWatchlistItem) { |
|
|
throw new HttpException( |
|
|
throw new HttpException( |
|
|
getReasonPhrase(StatusCodes.NOT_FOUND), |
|
|
getReasonPhrase(StatusCodes.NOT_FOUND), |
|
|
StatusCodes.NOT_FOUND |
|
|
StatusCodes.NOT_FOUND |
|
|
|
|
|
@ -152,4 +152,20 @@ export class WatchlistService { |
|
|
return a.name.localeCompare(b.name); |
|
|
return a.name.localeCompare(b.name); |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public async hasWatchlistItem({ |
|
|
|
|
|
dataSource, |
|
|
|
|
|
symbol, |
|
|
|
|
|
userId |
|
|
|
|
|
}: { userId: string } & AssetProfileIdentifier): Promise<boolean> { |
|
|
|
|
|
const assetProfile = await this.prismaService.symbolProfile.findFirst({ |
|
|
|
|
|
where: { |
|
|
|
|
|
dataSource, |
|
|
|
|
|
symbol, |
|
|
|
|
|
watchedBy: { some: { id: userId } } |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
return !!assetProfile; |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|