Skip to content

Commit 5177693

Browse files
committed
fixes
1 parent 0b2c142 commit 5177693

File tree

2 files changed

+24
-43
lines changed

2 files changed

+24
-43
lines changed

pgcommitfest/commitfest/models.py

Lines changed: 8 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,6 @@ def auto_move_active_patches(self):
149149
150150
A patch is moved if it has recent email activity and hasn't been
151151
failing CI for too long.
152-
153-
Returns a set of patch IDs that were moved.
154152
"""
155153
current_date = datetime.now()
156154

@@ -175,30 +173,17 @@ def auto_move_active_patches(self):
175173
status__in=PatchOnCommitFest.OPEN_STATUSES
176174
).select_related("patch")
177175

178-
moved_patch_ids = set()
179176
for poc in open_pocs:
180177
if self._should_auto_move_patch(poc.patch, current_date):
181178
poc.patch.move(self, next_cf, by_user=None, by_cfbot=True)
182-
moved_patch_ids.add(poc.patch.id)
183-
184-
return moved_patch_ids
185-
186-
def send_closure_notifications(self, moved_patch_ids=None):
187-
"""Send email notifications to authors of patches that weren't auto-moved.
188-
189-
Args:
190-
moved_patch_ids: Set of patch IDs that were auto-moved to the next commitfest.
191-
These patches are excluded since the move triggers its own notification.
192-
"""
193-
if moved_patch_ids is None:
194-
moved_patch_ids = set()
195179

180+
def send_closure_notifications(self):
181+
"""Send email notifications to authors of patches that are still open."""
196182
# Get patches that still need action (not moved, not closed)
197183
open_pocs = list(
198184
self.patchoncommitfest_set.filter(
199185
status__in=PatchOnCommitFest.OPEN_STATUSES
200186
)
201-
.exclude(patch_id__in=moved_patch_ids)
202187
.select_related("patch")
203188
.prefetch_related("patch__authors")
204189
)
@@ -292,19 +277,19 @@ def _refresh_relevant_commitfests(cls, for_update):
292277

293278
inprogress_cf = cfs["in_progress"]
294279
if inprogress_cf and inprogress_cf.enddate < current_date:
295-
moved_patch_ids = inprogress_cf.auto_move_active_patches()
280+
inprogress_cf.auto_move_active_patches()
296281
inprogress_cf.status = CommitFest.STATUS_CLOSED
297282
inprogress_cf.save()
298-
inprogress_cf.send_closure_notifications(moved_patch_ids)
283+
inprogress_cf.send_closure_notifications()
299284

300285
open_cf = cfs["open"]
301286

302287
if open_cf.startdate <= current_date:
303288
if open_cf.enddate < current_date:
304-
moved_patch_ids = open_cf.auto_move_active_patches()
289+
open_cf.auto_move_active_patches()
305290
open_cf.status = CommitFest.STATUS_CLOSED
306291
open_cf.save()
307-
open_cf.send_closure_notifications(moved_patch_ids)
292+
open_cf.send_closure_notifications()
308293
else:
309294
open_cf.status = CommitFest.STATUS_INPROGRESS
310295
open_cf.save()
@@ -316,10 +301,10 @@ def _refresh_relevant_commitfests(cls, for_update):
316301
cls.next_draft_cf(current_date).save()
317302
elif draft_cf.enddate < current_date:
318303
# If the draft commitfest has started, we need to update it
319-
moved_patch_ids = draft_cf.auto_move_active_patches()
304+
draft_cf.auto_move_active_patches()
320305
draft_cf.status = CommitFest.STATUS_CLOSED
321306
draft_cf.save()
322-
draft_cf.send_closure_notifications(moved_patch_ids)
307+
draft_cf.send_closure_notifications()
323308
cls.next_draft_cf(current_date).save()
324309

325310
return cls.relevant_commitfests(for_update=for_update)

pgcommitfest/commitfest/tests/test_closure_notifications.py

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,9 @@ def test_no_notification_for_withdrawn_patches(alice, in_progress_cf, open_cf, t
9393
status=PatchOnCommitFest.STATUS_WITHDRAWN,
9494
)
9595

96-
moved_patch_ids = in_progress_cf.auto_move_active_patches()
97-
in_progress_cf.send_closure_notifications(moved_patch_ids)
96+
in_progress_cf.auto_move_active_patches()
97+
in_progress_cf.send_closure_notifications()
9898

99-
assert patch.id not in moved_patch_ids
10099
assert QueuedMail.objects.count() == 0
101100

102101

@@ -261,8 +260,8 @@ def test_auto_move_patch_with_recent_email_activity(
261260
status=PatchOnCommitFest.STATUS_REVIEW,
262261
)
263262

264-
moved_patch_ids = in_progress_cf.auto_move_active_patches()
265-
in_progress_cf.send_closure_notifications(moved_patch_ids)
263+
in_progress_cf.auto_move_active_patches()
264+
in_progress_cf.send_closure_notifications()
266265

267266
# Patch should be moved
268267
patch.refresh_from_db()
@@ -298,8 +297,8 @@ def test_no_auto_move_without_email_activity(alice, in_progress_cf, open_cf, top
298297
status=PatchOnCommitFest.STATUS_REVIEW,
299298
)
300299

301-
moved_patch_ids = in_progress_cf.auto_move_active_patches()
302-
in_progress_cf.send_closure_notifications(moved_patch_ids)
300+
in_progress_cf.auto_move_active_patches()
301+
in_progress_cf.send_closure_notifications()
303302

304303
# Patch should NOT be moved
305304
patch.refresh_from_db()
@@ -339,8 +338,8 @@ def test_no_auto_move_when_failing_too_long(alice, in_progress_cf, open_cf, topi
339338
- timedelta(days=settings.AUTO_MOVE_MAX_FAILING_DAYS + 10),
340339
)
341340

342-
moved_patch_ids = in_progress_cf.auto_move_active_patches()
343-
in_progress_cf.send_closure_notifications(moved_patch_ids)
341+
in_progress_cf.auto_move_active_patches()
342+
in_progress_cf.send_closure_notifications()
344343

345344
# Patch should NOT be moved
346345
patch.refresh_from_db()
@@ -373,8 +372,8 @@ def test_auto_move_when_failing_within_threshold(alice, in_progress_cf, open_cf,
373372
- timedelta(days=settings.AUTO_MOVE_MAX_FAILING_DAYS - 5),
374373
)
375374

376-
moved_patch_ids = in_progress_cf.auto_move_active_patches()
377-
in_progress_cf.send_closure_notifications(moved_patch_ids)
375+
in_progress_cf.auto_move_active_patches()
376+
in_progress_cf.send_closure_notifications()
378377

379378
# Patch should be moved (failure is recent enough)
380379
patch.refresh_from_db()
@@ -399,9 +398,8 @@ def test_no_auto_move_with_null_lastmail(alice, in_progress_cf, open_cf, topic):
399398
status=PatchOnCommitFest.STATUS_REVIEW,
400399
)
401400

402-
moved_patch_ids = in_progress_cf.auto_move_active_patches()
401+
in_progress_cf.auto_move_active_patches()
403402

404-
assert patch.id not in moved_patch_ids
405403
patch.refresh_from_db()
406404
assert patch.current_commitfest().id == in_progress_cf.id
407405

@@ -423,10 +421,9 @@ def test_auto_move_patch_without_cfbot_branch(alice, in_progress_cf, open_cf, to
423421

424422
# No CfbotBranch created - CI never ran
425423

426-
moved_patch_ids = in_progress_cf.auto_move_active_patches()
427-
in_progress_cf.send_closure_notifications(moved_patch_ids)
424+
in_progress_cf.auto_move_active_patches()
425+
in_progress_cf.send_closure_notifications()
428426

429-
assert patch.id in moved_patch_ids
430427
patch.refresh_from_db()
431428
assert patch.current_commitfest().id == open_cf.id
432429

@@ -466,10 +463,9 @@ def test_regular_cf_does_not_move_to_draft_cf(alice, in_progress_cf, topic):
466463
status=PatchOnCommitFest.STATUS_REVIEW,
467464
)
468465

469-
moved_patch_ids = in_progress_cf.auto_move_active_patches()
466+
in_progress_cf.auto_move_active_patches()
470467

471468
# Should be moved to regular CF, not draft CF
472-
assert patch.id in moved_patch_ids
473469
patch.refresh_from_db()
474470
assert patch.current_commitfest().id == regular_cf.id
475471
assert patch.current_commitfest().id != draft_cf.id
@@ -507,8 +503,8 @@ def test_draft_cf_moves_active_patches_to_next_draft(alice, bob, topic):
507503
status=PatchOnCommitFest.STATUS_REVIEW,
508504
)
509505

510-
moved_patch_ids = closing_draft_cf.auto_move_active_patches()
511-
closing_draft_cf.send_closure_notifications(moved_patch_ids)
506+
closing_draft_cf.auto_move_active_patches()
507+
closing_draft_cf.send_closure_notifications()
512508

513509
# Patch should be moved to the next draft CF
514510
patch.refresh_from_db()

0 commit comments

Comments
 (0)