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 userEntity = await userRepository.findByPubkeyHex(context.pubKey)
|
||||||
const balanceEntity = await balanceRepository.findByUser(userEntity.id)
|
const balanceEntity = await balanceRepository.findByUser(userEntity.id)
|
||||||
let balance: Balance
|
|
||||||
const now = new Date()
|
const now = new Date()
|
||||||
if (balanceEntity) {
|
|
||||||
balance = new Balance({
|
// No balance found
|
||||||
|
if (!balanceEntity) {
|
||||||
|
return new Balance({
|
||||||
|
balance: 0,
|
||||||
|
decay: 0,
|
||||||
|
decay_date: now.toString(),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
return new Balance({
|
||||||
balance: roundFloorFrom4(balanceEntity.amount),
|
balance: roundFloorFrom4(balanceEntity.amount),
|
||||||
decay: roundFloorFrom4(
|
decay: roundFloorFrom4(
|
||||||
await calculateDecay(balanceEntity.amount, balanceEntity.recordDate, now),
|
await calculateDecay(balanceEntity.amount, balanceEntity.recordDate, now),
|
||||||
),
|
),
|
||||||
decay_date: now.toString(),
|
decay_date: now.toString(),
|
||||||
})
|
})
|
||||||
} else {
|
|
||||||
balance = new Balance({
|
|
||||||
balance: 0,
|
|
||||||
decay: 0,
|
|
||||||
decay_date: now.toString(),
|
|
||||||
})
|
|
||||||
}
|
|
||||||
return balance
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -50,7 +50,7 @@ async function calculateAndAddDecayTransactions(
|
|||||||
const transactionIndiced: dbTransaction[] = []
|
const transactionIndiced: dbTransaction[] = []
|
||||||
transactions.forEach((transaction: dbTransaction) => {
|
transactions.forEach((transaction: dbTransaction) => {
|
||||||
transactionIndiced[transaction.id] = transaction
|
transactionIndiced[transaction.id] = transaction
|
||||||
if (transaction.transactionTypeId === 2) {
|
if (transaction.transactionTypeId === TransactionTypeId.SEND) {
|
||||||
involvedUserIds.push(transaction.transactionSendCoin.userId)
|
involvedUserIds.push(transaction.transactionSendCoin.userId)
|
||||||
involvedUserIds.push(transaction.transactionSendCoin.recipiantUserId)
|
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
|
// group name if creation
|
||||||
// type: gesendet / empfangen / geschöpft
|
// type: gesendet / empfangen / geschöpft
|
||||||
// transaktion nr / id
|
// transaktion nr / id
|
||||||
@ -231,7 +231,7 @@ export class TransactionResolver {
|
|||||||
email: userEntity.email,
|
email: userEntity.email,
|
||||||
})
|
})
|
||||||
if (!resultGDTSum.success) throw new Error(resultGDTSum.data)
|
if (!resultGDTSum.success) throw new Error(resultGDTSum.data)
|
||||||
transactions.gdtSum = resultGDTSum.data.sum
|
transactions.gdtSum = resultGDTSum.data.sum || 0
|
||||||
|
|
||||||
// get balance
|
// get balance
|
||||||
const balanceRepository = getCustomRepository(BalanceRepository)
|
const balanceRepository = getCustomRepository(BalanceRepository)
|
||||||
|
|||||||
@ -4,8 +4,6 @@ import { Balance } from '../entity/Balance'
|
|||||||
@EntityRepository(Balance)
|
@EntityRepository(Balance)
|
||||||
export class BalanceRepository extends Repository<Balance> {
|
export class BalanceRepository extends Repository<Balance> {
|
||||||
findByUser(userId: number): Promise<Balance | undefined> {
|
findByUser(userId: number): Promise<Balance | undefined> {
|
||||||
return this.createQueryBuilder('balance')
|
return this.createQueryBuilder('balance').where('balance.userId = :userId', { userId }).getOne()
|
||||||
.where('balance.userId = :userId', { userId })
|
|
||||||
.getOneOrFail()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -43,11 +43,13 @@ services:
|
|||||||
# DATABASE ##############################################
|
# DATABASE ##############################################
|
||||||
########################################################
|
########################################################
|
||||||
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
|
# feel free to change this behaviour if it seems useful
|
||||||
#image: gradido/database:test_up
|
# Due to problems with the volume caching the built files
|
||||||
#build:
|
# we changed this to test build. This keeps the service running.
|
||||||
# target: test_up
|
image: gradido/database:test_up
|
||||||
|
build:
|
||||||
|
target: test_up
|
||||||
#networks:
|
#networks:
|
||||||
# - external-net
|
# - external-net
|
||||||
# - internal-net
|
# - internal-net
|
||||||
|
|||||||
@ -32,7 +32,7 @@ export const loginViaEmailVerificationCode = gql`
|
|||||||
`
|
`
|
||||||
|
|
||||||
export const transactionsQuery = 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) {
|
transactionList(currentPage: $currentPage, pageSize: $pageSize, order: $order) {
|
||||||
gdtSum
|
gdtSum
|
||||||
count
|
count
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user