Skip to content

Commit b08f074

Browse files
committed
Fix extra db dips per log line
1 parent 74d79f9 commit b08f074

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

api/resolvers/wallet.js

+15-8
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,10 @@ const resolvers = {
430430
lte: to ? new Date(Number(to)) : undefined
431431
}
432432
},
433+
include: {
434+
invoice: true,
435+
withdrawal: true
436+
},
433437
orderBy: [
434438
{ createdAt: 'desc' },
435439
{ id: 'desc' }
@@ -445,6 +449,10 @@ const resolvers = {
445449
lte: decodedCursor.time
446450
}
447451
},
452+
include: {
453+
invoice: true,
454+
withdrawal: true
455+
},
448456
orderBy: [
449457
{ createdAt: 'desc' },
450458
{ id: 'desc' }
@@ -748,20 +756,19 @@ const resolvers = {
748756
},
749757

750758
WalletLogEntry: {
751-
context: async ({ level, context, invoiceId, withdrawalId }, args, { models }) => {
759+
context: async ({ level, context, invoice, withdrawal }, args, { models }) => {
752760
const isError = ['error', 'warn'].includes(level.toLowerCase())
753761

754-
if (withdrawalId) {
755-
const wdrwl = await models.withdrawl.findUnique({ where: { id: withdrawalId } })
762+
if (withdrawal) {
756763
return {
757-
...await logContextFromBolt11(wdrwl.bolt11),
758-
...(wdrwl.preimage ? { preimage: wdrwl.preimage } : {}),
759-
...(isError ? { max_fee: formatMsats(wdrwl.msatsFeePaying) } : {})
764+
...await logContextFromBolt11(withdrawal.bolt11),
765+
...(withdrawal.preimage ? { preimage: withdrawal.preimage } : {}),
766+
...(isError ? { max_fee: formatMsats(withdrawal.msatsFeePaying) } : {})
760767
}
761768
}
762769

763-
if (invoiceId) {
764-
const inv = await models.invoice.findUnique({ where: { id: invoiceId } })
770+
if (invoice) {
771+
const inv = await models.invoice.findUnique({ where: { id: invoice.id } })
765772
return await logContextFromBolt11(inv.bolt11)
766773
}
767774

0 commit comments

Comments
 (0)