disconnect greedy rewards connection after they run

This commit is contained in:
keyan 2024-01-19 15:11:44 -06:00
parent d14123cc42
commit 64e49934d4

View File

@ -14,8 +14,10 @@ export async function earn ({ name }) {
// however for user gen subs currently only 50% of their fees go to rewards
// the other 50% goes to the founder of the sub
// grab a greedy connection
const models = new PrismaClient()
try {
// compute how much sn earned today
const [{ sum: sumDecimal }] = await models.$queryRaw`
SELECT coalesce(sum(msats), 0) as sum
@ -193,6 +195,9 @@ export async function earn ({ name }) {
Promise.allSettled(Object.entries(notifications).map(([userId, earnings]) =>
sendUserNotification(parseInt(userId, 10), buildUserNotification(earnings))
)).catch(console.error)
} finally {
models.$disconnect().catch(console.error)
}
}
async function territoryRevenue ({ models }) {