Move update_bank_balances to billing task, don't fail every provider if one fails (#4332)

This commit is contained in:
François-Xavier Talbot
2025-09-03 14:12:34 +01:00
committed by GitHub
parent d23b925bb9
commit bd918c7616
3 changed files with 45 additions and 33 deletions

View File

@@ -1,10 +1,12 @@
use crate::database::redis::RedisPool;
use crate::queue::payouts::process_payout;
use crate::queue::payouts::{
PayoutsQueue, insert_bank_balances, process_payout,
};
use crate::search::indexing::index_projects;
use crate::{database, search};
use clap::ValueEnum;
use sqlx::Postgres;
use tracing::{info, warn};
use tracing::{error, info, warn};
#[derive(ValueEnum, Debug, Copy, Clone, PartialEq, Eq)]
#[clap(rename_all = "kebab_case")]
@@ -37,10 +39,12 @@ impl BackgroundTask {
IndexBilling => {
crate::routes::internal::billing::index_billing(
stripe_client,
pool,
pool.clone(),
redis_pool,
)
.await
.await;
update_bank_balances(pool).await;
}
IndexSubscriptions => {
crate::routes::internal::billing::index_subscriptions(
@@ -52,6 +56,15 @@ impl BackgroundTask {
}
}
pub async fn update_bank_balances(pool: sqlx::Pool<Postgres>) {
let payouts_queue = PayoutsQueue::new();
match insert_bank_balances(&payouts_queue, &pool).await {
Ok(_) => info!("Bank balances updated successfully"),
Err(error) => error!(%error, "Bank balances update failed"),
}
}
pub async fn run_migrations() {
database::check_for_migrations()
.await