From e516a9f5a88ffb4f276da0548f23072f0f43bff2 Mon Sep 17 00:00:00 2001 From: Joseph Shearer Date: Mon, 1 Jul 2024 15:03:04 -0400 Subject: [PATCH] Log more details about created invoices --- crates/billing-integrations/src/stripe.rs | 32 ++++++++++++++--------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/crates/billing-integrations/src/stripe.rs b/crates/billing-integrations/src/stripe.rs index 4098e2d84e..47ec839c4f 100644 --- a/crates/billing-integrations/src/stripe.rs +++ b/crates/billing-integrations/src/stripe.rs @@ -716,21 +716,27 @@ pub async fn do_publish_invoices(cmd: &PublishInvoice) -> anyhow::Result<()> { status.message(), *subtotal_agg as f64 / 100.0 ); - for (tenant, subtotal) in - tenants - .iter() - .sorted_by(|(_, a), (_, b)| b.cmp(a)) - .take(match status { - InvoiceResult::Created(_) | InvoiceResult::Updated => 8, - InvoiceResult::NoDataMoved - | InvoiceResult::NoFullPipeline - | InvoiceResult::LessThanMinimum - | InvoiceResult::FreeTier => 0, - _ => 4, - }) - { + let limit = match status { + InvoiceResult::Created(_) | InvoiceResult::Updated => 30, + InvoiceResult::NoDataMoved + | InvoiceResult::NoFullPipeline + | InvoiceResult::LessThanMinimum + | InvoiceResult::FreeTier => 0, + _ => 4, + }; + let sorted_tenants = tenants + .iter() + .sorted_by(|(_, a), (_, b)| b.cmp(a)) + .collect_vec(); + + let (displayed_tenants, remainder_tenants) = + sorted_tenants.split_at(limit.min(tenants.len())); + for (tenant, subtotal) in displayed_tenants { tracing::info!(" - {:} ${:.2}", tenant, *subtotal as f64 / 100.0); } + if limit > 0 && remainder_tenants.len() > 0 { + tracing::info!(" - ... {} Others", remainder_tenants.len(),); + } } Ok(())