Merge ~pieq/oem-qa-autosummary:fix-lp1935771-new-bugs-mutable-default-args into oem-qa-autosummary:master

Proposed by Pierre Equoy
Status: Merged
Approved by: Pierre Equoy
Approved revision: 748f6ddabd5a883429636fd6f3e90a1d7d433048
Merged at revision: 30c3ccd1adff335f31b800a440276a6e7059500f
Proposed branch: ~pieq/oem-qa-autosummary:fix-lp1935771-new-bugs-mutable-default-args
Merge into: oem-qa-autosummary:master
Diff against target: 24 lines (+5/-1)
1 file modified
autosummary/summary.py (+5/-1)
Reviewer Review Type Date Requested Status
Kristin Chuang (community) Approve
Review via email: mp+405529@code.launchpad.net

Description of the change

This fixes lp:1935771.

See commit message for more information.

To test:

Use a project with a recent milestone, and make sure that the expected new bugs are retrieved.

Check in the logs for the phrase "Search bugs from {created_since} to {created_before} for {self.project_name} project", where created_before should change every time you request a new summary.

To post a comment you must log in.
Revision history for this message
Kristin Chuang (kristinchuang) wrote (last edit ):

works for me, +1

Tried out the changes in a local deployment around 2021-07-13 16:55:

[OK] correct `created_before` date detected:
https://pastebin.canonical.com/p/CdCQpZbkwv/ row #11

[OK] a correct set of new bugs returned

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/autosummary/summary.py b/autosummary/summary.py
2index c38c071..9a08276 100644
3--- a/autosummary/summary.py
4+++ b/autosummary/summary.py
5@@ -67,7 +67,7 @@ class Summary:
6 return user, passwd
7 return "", ""
8
9- def get_new_bugs(self, created_since=None, created_before=datetime.today()):
10+ def get_new_bugs(self, created_since=None, created_before=None):
11 """
12 Return a list of bugs that have been opened by a Canonical QA engineer
13 in the same project between `created_since` and `created_before`. Bugs
14@@ -78,6 +78,10 @@ class Summary:
15
16 if created_since is None:
17 created_since = self.image_date
18+
19+ if created_before is None:
20+ created_before = datetime.today()
21+
22 new_bugs = []
23 logging.info((f"Search bugs from {created_since} to {created_before}"
24 f" for {self.project_name} project"))

Subscribers

People subscribed via source and target branches

to all changes: