Automatically fail payments that are older than 30 days (#3697)

This commit is contained in:
Emma Alexia authored and GitHub committed 2025-05-25 19:36:19 +00:00
1 parent 84adf79564
commit 74cf3f076e
2 files changed
+27

No files matched your search

+12
View File
@@ -735,6 +735,18 @@ pub async fn process_payout(
pool: &PgPool,
client: &clickhouse::Client,
) -> Result<(), ApiError> {
sqlx::query!(
"
UPDATE payouts
SET status = $1
WHERE status = $2 AND created < NOW() - INTERVAL '30 days'
",
crate::models::payouts::PayoutStatus::Failed.as_str(),
crate::models::payouts::PayoutStatus::InTransit.as_str(),
)
.execute(pool)
.await?;
let start: DateTime<Utc> = DateTime::from_naive_utc_and_offset(
(Utc::now() - Duration::days(1))
.date_naive()