Merge lp:~al-maisan/launchpad/conflict-resolution-20100228 into lp:launchpad/db-devel

Proposed by Muharem Hrnjadovic
Status: Merged
Merged at revision: not available
Proposed branch: lp:~al-maisan/launchpad/conflict-resolution-20100228
Merge into: lp:launchpad/db-devel
Diff against target: 157 lines (+61/-4)
5 files modified
lib/lp/bugs/doc/bug-heat.txt (+8/-0)
lib/lp/bugs/scripts/bugheat.py (+18/-0)
lib/lp/bugs/scripts/tests/test_bugheat.py (+32/-2)
lib/lp/soyuz/doc/archive.txt (+1/-0)
lib/lp/soyuz/stories/soyuz/xx-person-packages.txt (+2/-2)
To merge this branch: bzr merge lp:~al-maisan/launchpad/conflict-resolution-20100228
Reviewer Review Type Date Requested Status
Michael Nelson (community) code Approve
Review via email: mp+20301@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Muharem Hrnjadovic (al-maisan) wrote :

Resolves the most recent merge conflict, the test modified by the branch that causes the conflict runs OK.

Revision history for this message
Michael Nelson (michael.nelson) wrote :

Thanks Muharem! That fixes the soyuz-related failures result of code that *didn't* conflict (as I had to use secure_record on devel for some new tests which were obviously not touched by bigjools' branch).

I'll email about the remaining max_bug_heat issue.

review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/bugs/doc/bug-heat.txt'
2--- lib/lp/bugs/doc/bug-heat.txt 2010-01-12 16:41:23 +0000
3+++ lib/lp/bugs/doc/bug-heat.txt 2010-02-28 14:13:18 +0000
4@@ -44,6 +44,14 @@
5 >>> bug_1.heat
6 0
7
8+We touch bug 1 to make sure its date_last_updated is recent enough (bug heat
9+decays over time).
10+
11+ >>> new_comment = bug_1.newMessage(
12+ ... owner=bug_1.owner, subject="...", content="...")
13+ >>> import transaction ; transaction.commit()
14+ >>> bug_1 = getUtility(IBugSet).get(1)
15+
16 >>> update_bug_heat(chunk_size=1)
17 DEBUG Updating 1 Bugs (starting id: ...)
18 ...
19
20=== modified file 'lib/lp/bugs/scripts/bugheat.py'
21--- lib/lp/bugs/scripts/bugheat.py 2010-02-01 11:56:15 +0000
22+++ lib/lp/bugs/scripts/bugheat.py 2010-02-28 14:13:18 +0000
23@@ -8,6 +8,9 @@
24 'BugHeatCalculator',
25 ]
26
27+from datetime import datetime
28+
29+from lp.bugs.interfaces.bugtask import RESOLVED_BUGTASK_STATUSES
30
31 class BugHeatConstants:
32
33@@ -56,8 +59,16 @@
34 len(direct_subscribers) + len(subscribers_from_dupes))
35 return subscriber_count * BugHeatConstants.SUBSCRIBER
36
37+ def _bugIsComplete(self):
38+ """Are all the tasks for this bug resolved?"""
39+ return all([(task.status in RESOLVED_BUGTASK_STATUSES)
40+ for task in self.bug.bugtasks])
41+
42 def getBugHeat(self):
43 """Return the total heat for the current bug."""
44+ if self._bugIsComplete():
45+ return 0
46+
47 total_heat = sum([
48 self._getHeatFromAffectedUsers(),
49 self._getHeatFromDuplicates(),
50@@ -66,5 +77,12 @@
51 self._getHeatFromSubscribers(),
52 ])
53
54+ # Bugs decay over time. Every month the bug isn't touched its heat
55+ # decreases by 10%.
56+ months = (
57+ datetime.utcnow() -
58+ self.bug.date_last_updated.replace(tzinfo=None)).days / 30
59+ total_heat = int(total_heat * (0.9 ** months))
60+
61 return total_heat
62
63
64=== modified file 'lib/lp/bugs/scripts/tests/test_bugheat.py'
65--- lib/lp/bugs/scripts/tests/test_bugheat.py 2010-01-12 16:41:23 +0000
66+++ lib/lp/bugs/scripts/tests/test_bugheat.py 2010-02-28 14:13:18 +0000
67@@ -1,4 +1,3 @@
68-
69 # Copyright 2010 Canonical Ltd. This software is licensed under the
70 # GNU Affero General Public License version 3 (see the file LICENSE).
71
72@@ -8,12 +7,14 @@
73
74 import unittest
75
76+from datetime import datetime, timedelta
77+
78 from canonical.testing import LaunchpadZopelessLayer
79
80+from lp.bugs.interfaces.bugtask import BugTaskStatus
81 from lp.bugs.scripts.bugheat import BugHeatCalculator, BugHeatConstants
82 from lp.testing import TestCaseWithFactory
83
84-
85 class TestBugHeatCalculator(TestCaseWithFactory):
86 """Tests for the BugHeatCalculator class."""
87
88@@ -177,6 +178,35 @@
89 "Expected bug heat did not match actual bug heat. "
90 "Expected %s, got %s" % (expected_heat, actual_heat))
91
92+ def test_getBugHeat_complete_bugs(self):
93+ # Bug which are in a resolved status don't have heat at all.
94+ complete_bug = self.factory.makeBug()
95+ heat = BugHeatCalculator(complete_bug).getBugHeat()
96+ self.assertNotEqual(
97+ 0, heat,
98+ "Expected bug heat did not match actual bug heat. "
99+ "Expected a positive value, got 0")
100+ complete_bug.bugtasks[0].transitionToStatus(
101+ BugTaskStatus.INVALID, complete_bug.owner)
102+ heat = BugHeatCalculator(complete_bug).getBugHeat()
103+ self.assertEqual(
104+ 0, heat,
105+ "Expected bug heat did not match actual bug heat. "
106+ "Expected %s, got %s" % (0, heat))
107+
108+ def test_getBugHeat_decay(self):
109+ # Every month, a bug that wasn't touched has its heat reduced by 10%.
110+ aging_bug = self.factory.makeBug()
111+ fresh_heat = BugHeatCalculator(aging_bug).getBugHeat()
112+ aging_bug.date_last_updated = (
113+ aging_bug.date_last_updated - timedelta(days=32))
114+ expected = int(fresh_heat * 0.9)
115+ heat = BugHeatCalculator(aging_bug).getBugHeat()
116+ self.assertEqual(
117+ expected, heat,
118+ "Expected bug heat did not match actual bug heat. "
119+ "Expected %s, got %s" % (expected, heat))
120+
121
122 def test_suite():
123 return unittest.TestLoader().loadTestsFromName(__name__)
124
125=== modified file 'lib/lp/soyuz/doc/archive.txt'
126--- lib/lp/soyuz/doc/archive.txt 2010-02-27 20:20:03 +0000
127+++ lib/lp/soyuz/doc/archive.txt 2010-02-28 14:13:18 +0000
128@@ -1835,6 +1835,7 @@
129 limited to 5 items.
130
131 >>> create_activity(cprov_archive, 20)
132+ >>> transaction.commit()
133 >>> print_most_active_ppas()
134 PPA for Celso Providelo 20
135 PPA for Foo Bar 10
136
137=== modified file 'lib/lp/soyuz/stories/soyuz/xx-person-packages.txt'
138--- lib/lp/soyuz/stories/soyuz/xx-person-packages.txt 2010-02-27 20:20:03 +0000
139+++ lib/lp/soyuz/stories/soyuz/xx-person-packages.txt 2010-02-28 14:13:18 +0000
140@@ -265,7 +265,7 @@
141 >>> mark_private_ppa = factory.makeArchive(
142 ... owner=mark, name="p3a", distribution=ubuntu, private=True)
143 >>> from zope.security.proxy import removeSecurityProxy
144- >>> removeSecurityProxy(source1_mark.secure_record).archive = (
145+ >>> removeSecurityProxy(source1_mark).archive = (
146 ... mark_private_ppa)
147 >>> logout()
148 >>> user_browser.open("http://launchpad.dev/~cprov/+related-software")
149@@ -288,7 +288,7 @@
150 >>> login('admin@canonical.com')
151 >>> cprov_private_ppa = factory.makeArchive(
152 ... owner=cprov, name="p3a", distribution=ubuntu, private=True)
153- >>> removeSecurityProxy(source1.secure_record).archive = (
154+ >>> removeSecurityProxy(source1).archive = (
155 ... cprov_private_ppa)
156 >>> source1.sourcepackagerelease.upload_archive = cprov_private_ppa
157 >>> logout()

Subscribers

People subscribed via source and target branches

to status/vote changes: