You've already forked AstralRinth
forked from didirus/AstralRinth
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:
committed by
GitHub
parent
1bad1a57b0
commit
7437a833ef
@@ -81,7 +81,7 @@ impl NotificationBuilder {
|
||||
'amount', to_jsonb(sum)
|
||||
) body
|
||||
FROM period_payouts
|
||||
WHERE sum > 0
|
||||
WHERE sum >= 100
|
||||
",
|
||||
¬ification_ids[..],
|
||||
&users_raw_ids[..],
|
||||
|
||||
@@ -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?;
|
||||
|
||||
@@ -631,7 +631,7 @@ async fn collect_template_variables(
|
||||
|
||||
map.insert(
|
||||
PAYOUTAVAILABLE_AMOUNT,
|
||||
format!("USD${:.2}", *amount as f64 / 100.0),
|
||||
format!("${:.2} USD", *amount as f64 / 100.0),
|
||||
);
|
||||
|
||||
Ok(EmailTemplate::Static(map))
|
||||
|
||||
@@ -1355,6 +1355,7 @@ pub async fn index_payouts_notifications(
|
||||
|
||||
payouts_values_notifications::synchronize_future_payout_values(
|
||||
&mut *transaction,
|
||||
200,
|
||||
)
|
||||
.await?;
|
||||
let items = payouts_values_notifications::PayoutsValuesNotification::unnotified_users_with_available_payouts_with_limit(&mut *transaction, 200).await?;
|
||||
|
||||
Reference in New Issue
Block a user