From f04f3bcbfc2ee56b1fad9771864cd1c9bf73bf66 Mon Sep 17 00:00:00 2001 From: Anders Kaseorg Date: Fri, 10 Oct 2025 01:48:57 -0700 Subject: [PATCH] stripe: Order downgrade_small_realms_behind_on_payments_as_needed query. Fixes nondeterminism that broke test_downgrade_small_realms_behind_on_payments_as_needed. Signed-off-by: Anders Kaseorg --- corporate/lib/stripe.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/corporate/lib/stripe.py b/corporate/lib/stripe.py index f493480240..a01f0f5953 100644 --- a/corporate/lib/stripe.py +++ b/corporate/lib/stripe.py @@ -5702,7 +5702,9 @@ def customer_has_last_n_invoices_open(customer: Customer, n: int) -> bool: def downgrade_small_realms_behind_on_payments_as_needed() -> None: - customers = Customer.objects.all().exclude(stripe_customer_id=None).exclude(realm=None) + customers = ( + Customer.objects.all().exclude(stripe_customer_id=None).exclude(realm=None).order_by("id") + ) for customer in customers: realm = customer.realm assert realm is not None