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