Merge lp:~intellectronica/launchpad/heat-decay-complete into lp:launchpad
| Status: | Merged | ||||||||
|---|---|---|---|---|---|---|---|---|---|
| Approved by: | Edwin Grubbs on 2010-02-26 | ||||||||
| Approved revision: | not available | ||||||||
| Merged at revision: | not available | ||||||||
| Proposed branch: | lp:~intellectronica/launchpad/heat-decay-complete | ||||||||
| Merge into: | lp:launchpad | ||||||||
| Diff against target: |
130 lines (+58/-2) 3 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) |
||||||||
| To merge this branch: | bzr merge lp:~intellectronica/launchpad/heat-decay-complete | ||||||||
| Related bugs: |
|
| Reviewer | Review Type | Date Requested | Status |
|---|---|---|---|
| Edwin Grubbs (community) | code | 2010-02-26 | Approve on 2010-02-26 |
|
Review via email:
|
|||
| Eleanor Berger (intellectronica) wrote : | # |
| Edwin Grubbs (edwin-grubbs) wrote : | # |
Hi Tom,
This is a nice branch. I have a few comments below, and there are some
lint errors.
merge-conditional
-Edwin
== Pyflakes notices ==
lib/lp/
13: 'getUtility' imported but unused
14: 'implements' imported but unused
16: 'ITunableLoop' imported but unused
17: 'DBLoopTuner' imported but unused
lib/lp/
10: 'datetime' imported but unused
>=== modified file 'lib/lp/
>--- lib/lp/
>+++ lib/lp/
>@@ -8,6 +8,7 @@
> 'BugHeatCalcula
> ]
>
>+from datetime import datetime
>
> from zope.component import getUtility
> from zope.interface import implements
>@@ -15,6 +16,8 @@
> from canonical.
> from canonical.
>
>+from lp.bugs.
>+
>
> class BugHeatConstants:
>
>@@ -63,8 +66,16 @@
> len(direct_
> return subscriber_count * BugHeatConstant
>
>+ def _bugIsComplete(
>+ """Are all the tasks for this bug resolved?"""
>+ return all([(task.status in RESOLVED_
>+ for task in self.bug.bugtasks])
>+
> def getBugHeat(self):
> """Return the total heat for the current bug."""
>+ if self._bugIsComp
>+ return 0
>+
> total_heat = sum([
> self._getHeatFr
> self._getHeatFr
>@@ -73,5 +84,15 @@
> self._getHeatFr
> ])
>
>+ # Bugs decay over time. Every month the bug isn't touched its heat
>+ # decreeses by 5%.
s/decreeses/
The comment says 5%, but the test says 10%. Which is it?
>+ months = (
>+ datetime.utcnow() -
>+ self.bug.
>+ for i in range(months):
>+ total_heat = total_heat * 0.95
This could be simplified as:
total_heat *= 0.95 ** months
>+
>+ total_heat = int(total_heat)
>+
> return total_heat
>
>
>=== modified file 'lib/lp/
>--- lib/lp/
>+++ lib/lp/
>@@ -1,4 +1,3 @@
>-
> # Copyright 2010 Canonical Ltd. This software is licensed under the
> # GNU Affero General Public License version 3 (see the file LICENSE).
>
>@@ -8,12 +7,14 @@
>
> import unittest
>
>+from datetime import datetime, timedelta
>+
> from canonical.testing import LaunchpadZopele
>
>+from lp.bugs.
> from lp.bugs.
> from lp.testing import TestCaseWithFactory
>
>-
> class TestBugHeatCalc
> """Tests for the BugHeatCalculator class."""
>
>@@ -177,6 +178,35 @@
> "Expected bug heat did not match actual bug heat. "
> "E...

This branch fixes two small bug heat related issues:
1. Bugs with a resolved status for all their tasks don't have any heat at all.
2. Bug heat decays over time. For every month that passes without the bug being touched it loses 10% of its heat.
I've added unit tests.