Fix payout notifications (#4707)

* Add limit to payouts_values_notifications synchronizer

* Set payout notification threshold to $1

* Fix formatting

* Query cache
This commit is contained in:
François-Xavier Talbot
2025-11-05 11:43:59 -08:00
committed by GitHub
parent 1bad1a57b0
commit 7437a833ef
6 changed files with 13 additions and 7 deletions

View File

@@ -81,7 +81,7 @@ impl NotificationBuilder {
'amount', to_jsonb(sum)
) body
FROM period_payouts
WHERE sum > 0
WHERE sum >= 100
",
&notification_ids[..],
&users_raw_ids[..],

View File

@@ -56,6 +56,7 @@ impl PayoutsValuesNotification {
pub async fn synchronize_future_payout_values(
exec: impl sqlx::PgExecutor<'_>,
limit: i64,
) -> Result<(), DatabaseError> {
sqlx::query!(
"
@@ -63,8 +64,10 @@ pub async fn synchronize_future_payout_values(
SELECT DISTINCT date_available, user_id, false notified
FROM payouts_values
WHERE date_available > NOW()
LIMIT $1
ON CONFLICT (date_available, user_id) DO NOTHING
",
limit,
)
.execute(exec)
.await?;