Merge pull request #931 from gradido/bug_fixes_recent_changes

Bug fixes recent changes
This commit is contained in:
einhornimmond 2021-10-02 13:05:46 +02:00 committed by GitHub
commit 232e28a413
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 23 additions and 23 deletions

View File

@ -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(),
})
}
}

View File

@ -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)

View File

@ -4,8 +4,6 @@ import { Balance } from '../entity/Balance'
@EntityRepository(Balance)
export class BalanceRepository extends Repository<Balance> {
findByUser(userId: number): Promise<Balance | undefined> {
return this.createQueryBuilder('balance')
.where('balance.userId = :userId', { userId })
.getOneOrFail()
return this.createQueryBuilder('balance').where('balance.userId = :userId', { userId }).getOne()
}
}

View File

@ -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

View File

@ -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