Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion apps/labrinth/src/background_task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,8 @@ pub async fn payouts(
}

pub async fn sync_payout_statuses(pool: sqlx::Pool<Postgres>, mural: MuralPay) {
const LIMIT: u32 = 1000;
// Mural sets a max limit of 100 for search payouts endpoint
const LIMIT: u32 = 100;

info!("Started syncing payout statuses");

Expand Down
6 changes: 3 additions & 3 deletions apps/labrinth/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use queue::{
session::AuthQueue, socket::ActiveSockets,
};
use sqlx::Postgres;
use tracing::{info, warn};
use tracing::{debug, info, warn};

extern crate clickhouse as clickhouse_crate;
use clickhouse_crate::Client;
Expand Down Expand Up @@ -240,14 +240,14 @@ pub fn app_setup(
let redis_ref = redis_ref.clone();

async move {
info!("Indexing analytics queue");
debug!("Indexing analytics queue");
let result = analytics_queue_ref
.index(client_ref, &redis_ref, &pool_ref)
.await;
if let Err(e) = result {
warn!("Indexing analytics queue failed: {:?}", e);
}
info!("Done indexing analytics queue");
debug!("Done indexing analytics queue");
}
});
}
Expand Down
18 changes: 17 additions & 1 deletion apps/labrinth/src/queue/payouts/mural.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use muralpay::{MuralError, MuralPay, TokenFeeRequest};
use rust_decimal::{Decimal, prelude::ToPrimitive};
use serde::{Deserialize, Serialize};
use sqlx::PgPool;
use tracing::warn;
use tracing::{info, warn};

use crate::{
database::models::DBPayoutId,
Expand Down Expand Up @@ -271,6 +271,8 @@ pub async fn sync_pending_payouts_from_mural(
status: PayoutStatus,
}

info!("Syncing pending payouts from Mural");

let mut txn = db
.begin()
.await
Expand Down Expand Up @@ -299,6 +301,8 @@ pub async fn sync_pending_payouts_from_mural(
.await
.wrap_internal_err("failed to fetch incomplete Mural payouts")?;

info!("Found {} incomplete Mural payouts", rows.len());

let futs = rows.into_iter().map(|row| async move {
let platform_id = row.platform_id.wrap_err("no platform ID")?;
let payout_request_id = platform_id.parse::<muralpay::PayoutRequestId>()
Expand Down Expand Up @@ -369,6 +373,8 @@ pub async fn sync_failed_mural_payouts_to_labrinth(
mural: &MuralPay,
limit: u32,
) -> eyre::Result<()> {
info!("Syncing failed Mural payouts to Labrinth");

let mut next_id = None;
loop {
let search_resp = mural
Expand All @@ -393,6 +399,11 @@ pub async fn sync_failed_mural_payouts_to_labrinth(
break;
}

info!(
"Found {} canceled or failed Mural payouts",
search_resp.results.len()
);

let mut payout_platform_id = Vec::<String>::new();
let mut payout_new_status = Vec::<String>::new();

Expand Down Expand Up @@ -430,6 +441,11 @@ pub async fn sync_failed_mural_payouts_to_labrinth(
.await
.wrap_internal_err("failed to update payout statuses")?;

info!(
"Updated {} payouts in database from Mural info",
payout_platform_id.len()
);

if next_id.is_none() {
break;
}
Expand Down