From a1d2b73790d9d28da5a79d75f7ca7381dfd565f2 Mon Sep 17 00:00:00 2001 From: Tim Abbott Date: Sun, 5 May 2019 18:13:21 -0700 Subject: [PATCH] soft_deactivation: Clarify loop logic around stream_messages. Break will do the same thing as continue here, as each iteration will have the same result, and it's also worth explaining why this isn't one layer up in the loop setup. --- zerver/lib/soft_deactivation.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/zerver/lib/soft_deactivation.py b/zerver/lib/soft_deactivation.py index 2fe140f32e..5561ccff3e 100644 --- a/zerver/lib/soft_deactivation.py +++ b/zerver/lib/soft_deactivation.py @@ -32,7 +32,10 @@ def filter_by_subscription_history(user_profile: UserProfile, for log_entry in stream_subscription_logs: if len(stream_messages) == 0: - continue + # Because stream_messages gets mutated below, this + # check belongs in this inner loop, not the outer loop. + break + if log_entry.event_type == RealmAuditLog.SUBSCRIPTION_DEACTIVATED: for stream_message in stream_messages: if stream_message['id'] <= log_entry.event_last_message_id: