From 60fbacb593049f50cb96038d7872a21b3b45f9e4 Mon Sep 17 00:00:00 2001 From: k00b Date: Tue, 17 Dec 2024 20:27:31 -0600 Subject: [PATCH] improve rewards cutoff criteria --- worker/earn.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/worker/earn.js b/worker/earn.js index bfb5348f4..019cf9bb1 100644 --- a/worker/earn.js +++ b/worker/earn.js @@ -51,6 +51,7 @@ export async function earn ({ name }) { */ // get earners { userId, id, type, rank, proportion, foreverReferrerId, oneDayReferrerId } + // has to earn at least 125000 msats to be eligible (so that they get at least 1 sat after referrals) const earners = await models.$queryRaw` WITH earners AS ( SELECT users.id AS "userId", users."referrerId" AS "foreverReferrerId", @@ -62,7 +63,7 @@ export async function earn ({ name }) { 'day') uv JOIN users ON users.id = uv.id WHERE NOT (users.id = ANY (${SN_NO_REWARDS_IDS})) - AND uv.proportion > 0.00000001 + AND uv.proportion >= 0.0000125 ORDER BY proportion DESC ) SELECT earners.*, @@ -85,7 +86,7 @@ export async function earn ({ name }) { let total = 0 const notifications = {} - for (const [earner] of earners.entries()) { + for (const [, earner] of earners.entries()) { const foreverReferrerEarnings = Math.floor(parseFloat(earner.proportion * sum * 0.1)) // 10% of earnings let oneDayReferrerEarnings = Math.floor(parseFloat(earner.proportion * sum * 0.1)) // 10% of earnings const earnerEarnings = Math.floor(parseFloat(earner.proportion * sum)) - foreverReferrerEarnings - oneDayReferrerEarnings @@ -107,7 +108,7 @@ export async function earn ({ name }) { 'oneDayReferrer', earner.oneDayReferrerId, 'oneDayReferrerEarnings', oneDayReferrerEarnings) - if (earnerEarnings > 0) { + if (earnerEarnings > 1000) { stmts.push(...earnStmts({ msats: earnerEarnings, userId: earner.userId, @@ -139,7 +140,7 @@ export async function earn ({ name }) { } } - if (earner.foreverReferrerId && foreverReferrerEarnings > 0) { + if (earner.foreverReferrerId && foreverReferrerEarnings > 1000) { stmts.push(...earnStmts({ msats: foreverReferrerEarnings, userId: earner.foreverReferrerId, @@ -152,7 +153,7 @@ export async function earn ({ name }) { oneDayReferrerEarnings += foreverReferrerEarnings } - if (earner.oneDayReferrerId && oneDayReferrerEarnings > 0) { + if (earner.oneDayReferrerId && oneDayReferrerEarnings > 1000) { stmts.push(...earnStmts({ msats: oneDayReferrerEarnings, userId: earner.oneDayReferrerId,