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
=== modified file 'lib/lp/bugs/doc/bug-heat.txt'
--- lib/lp/bugs/doc/bug-heat.txt 2010-01-12 16:41:23 +0000
+++ lib/lp/bugs/doc/bug-heat.txt 2010-02-28 14:13:18 +0000
@@ -44,6 +44,14 @@
44 >>> bug_1.heat44 >>> bug_1.heat
45 045 0
4646
47We touch bug 1 to make sure its date_last_updated is recent enough (bug heat
48decays over time).
49
50 >>> new_comment = bug_1.newMessage(
51 ... owner=bug_1.owner, subject="...", content="...")
52 >>> import transaction ; transaction.commit()
53 >>> bug_1 = getUtility(IBugSet).get(1)
54
47 >>> update_bug_heat(chunk_size=1)55 >>> update_bug_heat(chunk_size=1)
48 DEBUG Updating 1 Bugs (starting id: ...)56 DEBUG Updating 1 Bugs (starting id: ...)
49 ...57 ...
5058
=== modified file 'lib/lp/bugs/scripts/bugheat.py'
--- lib/lp/bugs/scripts/bugheat.py 2010-02-01 11:56:15 +0000
+++ lib/lp/bugs/scripts/bugheat.py 2010-02-28 14:13:18 +0000
@@ -8,6 +8,9 @@
8 'BugHeatCalculator',8 'BugHeatCalculator',
9 ]9 ]
1010
11from datetime import datetime
12
13from lp.bugs.interfaces.bugtask import RESOLVED_BUGTASK_STATUSES
1114
12class BugHeatConstants:15class BugHeatConstants:
1316
@@ -56,8 +59,16 @@
56 len(direct_subscribers) + len(subscribers_from_dupes))59 len(direct_subscribers) + len(subscribers_from_dupes))
57 return subscriber_count * BugHeatConstants.SUBSCRIBER60 return subscriber_count * BugHeatConstants.SUBSCRIBER
5861
62 def _bugIsComplete(self):
63 """Are all the tasks for this bug resolved?"""
64 return all([(task.status in RESOLVED_BUGTASK_STATUSES)
65 for task in self.bug.bugtasks])
66
59 def getBugHeat(self):67 def getBugHeat(self):
60 """Return the total heat for the current bug."""68 """Return the total heat for the current bug."""
69 if self._bugIsComplete():
70 return 0
71
61 total_heat = sum([72 total_heat = sum([
62 self._getHeatFromAffectedUsers(),73 self._getHeatFromAffectedUsers(),
63 self._getHeatFromDuplicates(),74 self._getHeatFromDuplicates(),
@@ -66,5 +77,12 @@
66 self._getHeatFromSubscribers(),77 self._getHeatFromSubscribers(),
67 ])78 ])
6879
80 # Bugs decay over time. Every month the bug isn't touched its heat
81 # decreases by 10%.
82 months = (
83 datetime.utcnow() -
84 self.bug.date_last_updated.replace(tzinfo=None)).days / 30
85 total_heat = int(total_heat * (0.9 ** months))
86
69 return total_heat87 return total_heat
7088
7189
=== modified file 'lib/lp/bugs/scripts/tests/test_bugheat.py'
--- lib/lp/bugs/scripts/tests/test_bugheat.py 2010-01-12 16:41:23 +0000
+++ lib/lp/bugs/scripts/tests/test_bugheat.py 2010-02-28 14:13:18 +0000
@@ -1,4 +1,3 @@
1
2# Copyright 2010 Canonical Ltd. This software is licensed under the1# Copyright 2010 Canonical Ltd. This software is licensed under the
3# GNU Affero General Public License version 3 (see the file LICENSE).2# GNU Affero General Public License version 3 (see the file LICENSE).
43
@@ -8,12 +7,14 @@
87
9import unittest8import unittest
109
10from datetime import datetime, timedelta
11
11from canonical.testing import LaunchpadZopelessLayer12from canonical.testing import LaunchpadZopelessLayer
1213
14from lp.bugs.interfaces.bugtask import BugTaskStatus
13from lp.bugs.scripts.bugheat import BugHeatCalculator, BugHeatConstants15from lp.bugs.scripts.bugheat import BugHeatCalculator, BugHeatConstants
14from lp.testing import TestCaseWithFactory16from lp.testing import TestCaseWithFactory
1517
16
17class TestBugHeatCalculator(TestCaseWithFactory):18class TestBugHeatCalculator(TestCaseWithFactory):
18 """Tests for the BugHeatCalculator class."""19 """Tests for the BugHeatCalculator class."""
1920
@@ -177,6 +178,35 @@
177 "Expected bug heat did not match actual bug heat. "178 "Expected bug heat did not match actual bug heat. "
178 "Expected %s, got %s" % (expected_heat, actual_heat))179 "Expected %s, got %s" % (expected_heat, actual_heat))
179180
181 def test_getBugHeat_complete_bugs(self):
182 # Bug which are in a resolved status don't have heat at all.
183 complete_bug = self.factory.makeBug()
184 heat = BugHeatCalculator(complete_bug).getBugHeat()
185 self.assertNotEqual(
186 0, heat,
187 "Expected bug heat did not match actual bug heat. "
188 "Expected a positive value, got 0")
189 complete_bug.bugtasks[0].transitionToStatus(
190 BugTaskStatus.INVALID, complete_bug.owner)
191 heat = BugHeatCalculator(complete_bug).getBugHeat()
192 self.assertEqual(
193 0, heat,
194 "Expected bug heat did not match actual bug heat. "
195 "Expected %s, got %s" % (0, heat))
196
197 def test_getBugHeat_decay(self):
198 # Every month, a bug that wasn't touched has its heat reduced by 10%.
199 aging_bug = self.factory.makeBug()
200 fresh_heat = BugHeatCalculator(aging_bug).getBugHeat()
201 aging_bug.date_last_updated = (
202 aging_bug.date_last_updated - timedelta(days=32))
203 expected = int(fresh_heat * 0.9)
204 heat = BugHeatCalculator(aging_bug).getBugHeat()
205 self.assertEqual(
206 expected, heat,
207 "Expected bug heat did not match actual bug heat. "
208 "Expected %s, got %s" % (expected, heat))
209
180210
181def test_suite():211def test_suite():
182 return unittest.TestLoader().loadTestsFromName(__name__)212 return unittest.TestLoader().loadTestsFromName(__name__)
183213
=== modified file 'lib/lp/soyuz/doc/archive.txt'
--- lib/lp/soyuz/doc/archive.txt 2010-02-27 20:20:03 +0000
+++ lib/lp/soyuz/doc/archive.txt 2010-02-28 14:13:18 +0000
@@ -1835,6 +1835,7 @@
1835limited to 5 items.1835limited to 5 items.
18361836
1837 >>> create_activity(cprov_archive, 20)1837 >>> create_activity(cprov_archive, 20)
1838 >>> transaction.commit()
1838 >>> print_most_active_ppas()1839 >>> print_most_active_ppas()
1839 PPA for Celso Providelo 201840 PPA for Celso Providelo 20
1840 PPA for Foo Bar 101841 PPA for Foo Bar 10
18411842
=== modified file 'lib/lp/soyuz/stories/soyuz/xx-person-packages.txt'
--- lib/lp/soyuz/stories/soyuz/xx-person-packages.txt 2010-02-27 20:20:03 +0000
+++ lib/lp/soyuz/stories/soyuz/xx-person-packages.txt 2010-02-28 14:13:18 +0000
@@ -265,7 +265,7 @@
265 >>> mark_private_ppa = factory.makeArchive(265 >>> mark_private_ppa = factory.makeArchive(
266 ... owner=mark, name="p3a", distribution=ubuntu, private=True)266 ... owner=mark, name="p3a", distribution=ubuntu, private=True)
267 >>> from zope.security.proxy import removeSecurityProxy267 >>> from zope.security.proxy import removeSecurityProxy
268 >>> removeSecurityProxy(source1_mark.secure_record).archive = (268 >>> removeSecurityProxy(source1_mark).archive = (
269 ... mark_private_ppa)269 ... mark_private_ppa)
270 >>> logout()270 >>> logout()
271 >>> user_browser.open("http://launchpad.dev/~cprov/+related-software")271 >>> user_browser.open("http://launchpad.dev/~cprov/+related-software")
@@ -288,7 +288,7 @@
288 >>> login('admin@canonical.com')288 >>> login('admin@canonical.com')
289 >>> cprov_private_ppa = factory.makeArchive(289 >>> cprov_private_ppa = factory.makeArchive(
290 ... owner=cprov, name="p3a", distribution=ubuntu, private=True)290 ... owner=cprov, name="p3a", distribution=ubuntu, private=True)
291 >>> removeSecurityProxy(source1.secure_record).archive = (291 >>> removeSecurityProxy(source1).archive = (
292 ... cprov_private_ppa)292 ... cprov_private_ppa)
293 >>> source1.sourcepackagerelease.upload_archive = cprov_private_ppa293 >>> source1.sourcepackagerelease.upload_archive = cprov_private_ppa
294 >>> logout()294 >>> logout()

Subscribers

People subscribed via source and target branches

to status/vote changes: