This commit is contained in:
Brandon Thomas committed 2026-04-12 21:20:07 -04:00
1 parent bbf2bf2b35
commit 7dbacc2d8a
2 files changed
+34 -27

No files matched your search

@@ -14,9 +14,12 @@ use crate::jobs::video_polling_job::process_job::process_successful_job::process
/// processed again in subsequent batches.
pub async fn process_orders_batch(
deps: &JobDependencies,
orders: &[OrderStatus],
kinovi_orders: &[OrderStatus],
job_by_order_id: &mut HashMap<String, PendingSeedance2ProJob>,
pages_in_current_batch: u32,
) {
log_batch_summary(&kinovi_orders, pages_in_current_batch);
let pending_job_count = job_by_order_id.len();
let mut batch_succeeded = 0u32;
@@ -24,7 +27,7 @@ pub async fn process_orders_batch(
let mut batch_in_progress = 0u32;
let mut batch_matched = 0u32;
for order in orders {
for order in kinovi_orders {
let job = match job_by_order_id.remove(&order.order_id) {
Some(j) => j,
None => continue, // Not one of our pending jobs.
@@ -72,7 +75,7 @@ pub async fn process_orders_batch(
{} kinovi orders in batch matched pending jobs \
(orders succeeded={}, orders failed={}, orders in_progress={}), \
{} pending db jobs in batch remaining",
orders.len(),
kinovi_orders.len(),
pending_job_count,
batch_matched,
batch_succeeded,
@@ -81,3 +84,24 @@ pub async fn process_orders_batch(
job_by_order_id.len(),
);
}
fn log_batch_summary(orders: &[OrderStatus], pages_in_batch: u32) {
let mut succeeded = 0u32;
let mut failed = 0u32;
let mut in_progress = 0u32;
let mut unknown = 0u32;
for order in orders {
match &order.task_status {
TaskStatus::Completed => succeeded += 1,
TaskStatus::Failed => failed += 1,
TaskStatus::Pending | TaskStatus::Processing => in_progress += 1,
TaskStatus::Unknown(_) => unknown += 1,
}
}
info!(
"Processing batch of {} Kinovi order pages, {} total orders (succeeded={}, failed={}, in_progress={}, unknown={})",
pages_in_batch, orders.len(), succeeded, failed, in_progress, unknown
);
}
@@ -152,7 +152,7 @@ async fn website_polling_loop(
pages_in_current_batch += 1;
info!("Done polling page {}. Got {} orders on this page.", total_pages_seen, page_orders_count);
info!("Done polling Kinovi orders page {}. Got {} orders on this page.", total_pages_seen, page_orders_count);
// Check if the last (oldest) order in this page exceeds the max age threshold.
// Orders are returned newest-first, so the last order is the oldest.
@@ -195,9 +195,12 @@ async fn website_polling_loop(
let should_process_batch_now = reached_end || batch_is_full;
if should_process_batch_now && !batch_orders.is_empty() {
log_batch_summary(&batch_orders, pages_in_current_batch);
process_orders_batch(deps, &batch_orders, &mut job_by_order_id).await;
process_orders_batch(
deps,
&batch_orders,
&mut job_by_order_id,
pages_in_current_batch
).await;
batch_orders.clear();
pages_in_current_batch = 0;
@@ -220,23 +223,3 @@ async fn website_polling_loop(
})
}
fn log_batch_summary(orders: &[OrderStatus], pages_in_batch: u32) {
let mut succeeded = 0u32;
let mut failed = 0u32;
let mut in_progress = 0u32;
let mut unknown = 0u32;
for order in orders {
match &order.task_status {
TaskStatus::Completed => succeeded += 1,
TaskStatus::Failed => failed += 1,
TaskStatus::Pending | TaskStatus::Processing => in_progress += 1,
TaskStatus::Unknown(_) => unknown += 1,
}
}
info!(
"Processing batch of {} Kinovi order pages, {} total orders (succeeded={}, failed={}, in_progress={}, unknown={})",
pages_in_batch, orders.len(), succeeded, failed, in_progress, unknown
);
}