Browse Source

Bugfix/race condition in upsert of account balance (#8306)

* Fix race condition in upsert of account balance

* Update changelog
pull/8311/head^2
Thomas Kaul 3 days ago
committed by GitHub
parent
commit
1de6f660c1
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 1
      CHANGELOG.md
  2. 14
      apps/api/src/app/account-balance/account-balance.service.ts

1
CHANGELOG.md

@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed ### Fixed
- Fixed a race condition in the creation of an account balance
- Fixed the handling of an output of the model which does not agree with the schema in the import of activities with _Ghostfolio AI_ (experimental) - Fixed the handling of an output of the model which does not agree with the schema in the import of activities with _Ghostfolio AI_ (experimental)
## 3.92.0 - 2026-10-24 ## 3.92.0 - 2026-10-24

14
apps/api/src/app/account-balance/account-balance.service.ts

@ -51,17 +51,13 @@ export class AccountBalanceService {
}: CreateAccountBalanceDto & { }: CreateAccountBalanceDto & {
userId: string; userId: string;
}): Promise<AccountBalance> { }): Promise<AccountBalance> {
const dateOfBalance = resetHours(parseISO(date));
const accountBalance = await this.prismaService.accountBalance.upsert({ const accountBalance = await this.prismaService.accountBalance.upsert({
create: { create: {
account: { accountId,
connect: {
id_userId: {
userId, userId,
id: accountId date: dateOfBalance,
}
}
},
date: resetHours(parseISO(date)),
value: balance value: balance
}, },
update: { update: {
@ -71,7 +67,7 @@ export class AccountBalanceService {
accountId_userId_date: { accountId_userId_date: {
accountId, accountId,
userId, userId,
date: resetHours(parseISO(date)) date: dateOfBalance
} }
} }
}); });

Loading…
Cancel
Save