From b765bb8446964697eb7acedff38be1e906ad0f07 Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Tue, 18 Feb 2025 09:42:29 +0100 Subject: [PATCH] [FIX] forwardport: a source may be unmerged Since forever, if a PR gets added to an existing forward ported batch it will be forward ported immediately, leading to a forwardport having a source with no merge date. Since the addition of the skipmerge feature, it's even more possible than before. As a result, the `outstanding` listing should not assume the merge_date of a source is always set. --- forwardport/controllers.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/forwardport/controllers.py b/forwardport/controllers.py index 43f6eb89..8f36784a 100644 --- a/forwardport/controllers.py +++ b/forwardport/controllers.py @@ -59,11 +59,12 @@ class Dashboard(MergebotDashboard): if reviewers: partner_filter.append([(f'source_id.reviewed_by{suffix}', '=', arg)]) + now = datetime.datetime.now() outstanding = PullRequests.search([ ('source_id', '!=', False), ('blocked', '!=', False), ('state', 'in', ['opened', 'validated', 'approved', 'ready', 'error']), - ('create_date', '<', datetime.datetime.now() - DEFAULT_DELTA), + ('create_date', '<', now - DEFAULT_DELTA), *(partner_filter and expression.OR(partner_filter)), ]) @@ -71,7 +72,7 @@ class Dashboard(MergebotDashboard): outstanding_per_author = collections.Counter() outstanding_per_reviewer = collections.Counter() outstandings = [] - for source in outstanding.mapped('source_id').sorted('merge_date'): + for source in outstanding.mapped('source_id').sorted(lambda s: s.merge_date or now): prs = source.forwardport_ids.filtered(lambda p: p.state not in ['merged', 'closed']) outstandings.append({ 'source': source,