rename right to GDT_BALANCE, rename query to gdtBalance, ensure gdtBalance is null when API call fails

This commit is contained in:
Moriz Wahl 2022-03-29 01:12:07 +02:00
parent d584651fc1
commit e9e97549a7
3 changed files with 5 additions and 5 deletions

View File

@ -21,7 +21,7 @@ export class BalanceResolver {
const now = new Date()
const gdtResolver = new GdtResolver()
const balanceGDT = await gdtResolver.gdtSum(context)
const balanceGDT = await gdtResolver.gdtBalance(context)
const lastTransaction = await Transaction.findOne(
{ userId: user.id },

View File

@ -33,9 +33,9 @@ export class GdtResolver {
}
}
@Authorized([RIGHTS.GDT_SUM])
@Authorized([RIGHTS.GDT_BALANCE])
@Query(() => Number)
async gdtSum(@Ctx() context: any): Promise<number | null> {
async gdtBalance(@Ctx() context: any): Promise<number | null> {
const { user } = context
try {
const resultGDTSum = await apiPost(`${CONFIG.GDT_API_URL}/GdtEntries/sumPerEmailApi`, {
@ -48,7 +48,7 @@ export class GdtResolver {
} catch (err: any) {
// eslint-disable-next-line no-console
console.log('Could not query GDT Server', err)
return 0
return null
}
}

View File

@ -156,7 +156,7 @@ export class TransactionResolver {
// get GDT
const gdtResolver = new GdtResolver()
const balanceGDT = await gdtResolver.gdtSum(context)
const balanceGDT = await gdtResolver.gdtBalance(context)
if (!lastTransaction) {
return new TransactionList(new Decimal(0), [], 0, 0, balanceGDT)