mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
Merge pull request #931 from gradido/bug_fixes_recent_changes
Bug fixes recent changes
This commit is contained in:
commit
232e28a413
@ -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(),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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()
|
||||
}
|
||||
}
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user