You've already forked AstralRinth
forked from didirus/AstralRinth
New Creator Notifications (#4383)
* Some new notification types * Fix error * Use existing DB models rather than inline queries * Fix template fillout * Fix ModerationThreadMessageReceived * Insert more notifications, fix some formatting * chore: query cache, clippy, fmt * chore: query cache, clippy, fmt * Use outer transactions to insert notifications instead of creating a new one * Join futures
This commit is contained in:
committed by
GitHub
parent
8149618187
commit
6da190ed01
@@ -1,3 +1,6 @@
|
||||
use crate::database::models::notification_item::NotificationBuilder;
|
||||
use crate::database::models::payouts_values_notifications;
|
||||
use crate::database::redis::RedisPool;
|
||||
use crate::models::payouts::{
|
||||
PayoutDecimal, PayoutInterval, PayoutMethod, PayoutMethodFee,
|
||||
PayoutMethodType,
|
||||
@@ -1084,6 +1087,41 @@ pub async fn insert_payouts(
|
||||
.await
|
||||
}
|
||||
|
||||
pub async fn index_payouts_notifications(
|
||||
pool: &PgPool,
|
||||
redis: &RedisPool,
|
||||
) -> Result<(), ApiError> {
|
||||
let mut transaction = pool.begin().await?;
|
||||
|
||||
payouts_values_notifications::synchronize_future_payout_values(
|
||||
&mut *transaction,
|
||||
)
|
||||
.await?;
|
||||
let items = payouts_values_notifications::PayoutsValuesNotification::unnotified_users_with_available_payouts_with_limit(&mut *transaction, 200).await?;
|
||||
|
||||
let payout_ref_ids = items.iter().map(|x| x.id).collect::<Vec<_>>();
|
||||
let dates_available =
|
||||
items.iter().map(|x| x.date_available).collect::<Vec<_>>();
|
||||
let user_ids = items.iter().map(|x| x.user_id).collect::<Vec<_>>();
|
||||
|
||||
NotificationBuilder::insert_many_payout_notifications(
|
||||
user_ids,
|
||||
dates_available,
|
||||
&mut transaction,
|
||||
redis,
|
||||
)
|
||||
.await?;
|
||||
payouts_values_notifications::PayoutsValuesNotification::set_notified_many(
|
||||
&payout_ref_ids,
|
||||
&mut *transaction,
|
||||
)
|
||||
.await?;
|
||||
|
||||
transaction.commit().await?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn insert_bank_balances_and_webhook(
|
||||
payouts: &PayoutsQueue,
|
||||
pool: &PgPool,
|
||||
|
||||
Reference in New Issue
Block a user