diff --git a/backend/src/graphql/resolvers/BalanceResolver.ts b/backend/src/graphql/resolvers/BalanceResolver.ts index 4c83bbbcd..642f32975 100644 --- a/backend/src/graphql/resolvers/BalanceResolver.ts +++ b/backend/src/graphql/resolvers/BalanceResolver.ts @@ -20,23 +20,23 @@ export class BalanceResolver { const userEntity = await userRepository.findByPubkeyHex(context.pubKey) const balanceEntity = await balanceRepository.findByUser(userEntity.id) - let balance: Balance const now = new Date() - if (balanceEntity) { - balance = new Balance({ - balance: roundFloorFrom4(balanceEntity.amount), - decay: roundFloorFrom4( - await calculateDecay(balanceEntity.amount, balanceEntity.recordDate, now), - ), - decay_date: now.toString(), - }) - } else { - balance = new Balance({ + + // No balance found + if (!balanceEntity) { + return new Balance({ balance: 0, decay: 0, decay_date: now.toString(), }) } - return balance + + return new Balance({ + balance: roundFloorFrom4(balanceEntity.amount), + decay: roundFloorFrom4( + await calculateDecay(balanceEntity.amount, balanceEntity.recordDate, now), + ), + decay_date: now.toString(), + }) } } diff --git a/backend/src/graphql/resolvers/TransactionResolver.ts b/backend/src/graphql/resolvers/TransactionResolver.ts index f079da9ca..f90eafff3 100644 --- a/backend/src/graphql/resolvers/TransactionResolver.ts +++ b/backend/src/graphql/resolvers/TransactionResolver.ts @@ -50,7 +50,7 @@ async function calculateAndAddDecayTransactions( const transactionIndiced: dbTransaction[] = [] transactions.forEach((transaction: dbTransaction) => { transactionIndiced[transaction.id] = transaction - if (transaction.transactionTypeId === 2) { + if (transaction.transactionTypeId === TransactionTypeId.SEND) { involvedUserIds.push(transaction.transactionSendCoin.userId) involvedUserIds.push(transaction.transactionSendCoin.recipiantUserId) } @@ -97,7 +97,7 @@ async function calculateAndAddDecayTransactions( } } - // sender or receiver when user has sended money + // sender or receiver when user has sent money // group name if creation // type: gesendet / empfangen / geschöpft // transaktion nr / id @@ -231,7 +231,7 @@ export class TransactionResolver { email: userEntity.email, }) if (!resultGDTSum.success) throw new Error(resultGDTSum.data) - transactions.gdtSum = resultGDTSum.data.sum + transactions.gdtSum = resultGDTSum.data.sum || 0 // get balance const balanceRepository = getCustomRepository(BalanceRepository) diff --git a/backend/src/typeorm/repository/Balance.ts b/backend/src/typeorm/repository/Balance.ts index 2cec58fdf..0938191e0 100644 --- a/backend/src/typeorm/repository/Balance.ts +++ b/backend/src/typeorm/repository/Balance.ts @@ -4,8 +4,6 @@ import { Balance } from '../entity/Balance' @EntityRepository(Balance) export class BalanceRepository extends Repository { findByUser(userId: number): Promise { - return this.createQueryBuilder('balance') - .where('balance.userId = :userId', { userId }) - .getOneOrFail() + return this.createQueryBuilder('balance').where('balance.userId = :userId', { userId }).getOne() } } diff --git a/docker-compose.override.yml b/docker-compose.override.yml index fda88943d..d14ce50f5 100644 --- a/docker-compose.override.yml +++ b/docker-compose.override.yml @@ -43,11 +43,13 @@ services: # DATABASE ############################################## ######################################################## database: - # we always run on prouction here since else the service lingers + # we always run on production here since else the service lingers # feel free to change this behaviour if it seems useful - #image: gradido/database:test_up - #build: - # target: test_up + # Due to problems with the volume caching the built files + # we changed this to test build. This keeps the service running. + image: gradido/database:test_up + build: + target: test_up #networks: # - external-net # - internal-net diff --git a/frontend/src/graphql/queries.js b/frontend/src/graphql/queries.js index 0aadb3345..c11abee50 100644 --- a/frontend/src/graphql/queries.js +++ b/frontend/src/graphql/queries.js @@ -32,7 +32,7 @@ export const loginViaEmailVerificationCode = gql` ` export const transactionsQuery = gql` - query($currentPage: Int = 1, $pageSize: Int = 25, $order: String = "DESC") { + query($currentPage: Int = 1, $pageSize: Int = 25, $order: Order = DESC) { transactionList(currentPage: $currentPage, pageSize: $pageSize, order: $order) { gdtSum count