Skip to content

Commit

Permalink
Log more details about created invoices
Browse files Browse the repository at this point in the history
  • Loading branch information
jshearer committed Oct 2, 2024
1 parent b562e71 commit e516a9f
Showing 1 changed file with 19 additions and 13 deletions.
32 changes: 19 additions & 13 deletions crates/billing-integrations/src/stripe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(())
Expand Down

0 comments on commit e516a9f

Please sign in to comment.