Code review comment for lp:~intellectronica/launchpad/bug-heat-days-active

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

There seems to be an inconsistency between the comment about the formula and the formula itself (regarding days_since_last_activity). From our IRC chat (below) and the related bug title, the comment should be:

> === modified file 'lib/lp/bugs/scripts/bugheat.py'
> --- lib/lp/bugs/scripts/bugheat.py 2010-04-22 12:14:18 +0000
> +++ lib/lp/bugs/scripts/bugheat.py 2010-04-22 12:14:19 +0000
> @@ -86,5 +86,19 @@
> self.bug.date_last_updated.replace(tzinfo=None)).days
> total_heat = int(total_heat * (0.99 ** days))
>
> - return total_heat
> + # Bug heat increases by a quarter of the maximum bug heat divided by
> + # the number of days between the bug's creating and its last activity.

         # the number of days since the bugs last activity.

> + days_since_last_activity = (
> + datetime.utcnow() -
> + max(self.bug.date_last_updated.replace(tzinfo=None),
> + self.bug.date_last_message.replace(tzinfo=None))).days
> + days_since_created = (
> + datetime.utcnow() - self.bug.datecreated.replace(tzinfo=None)).days
> + if days_since_created > 0:
> + max_heat = max(
> + task.target.max_bug_heat for task in self.bug.bugtasks)
> + if max_heat is not None:
> + total_heat = total_heat + (max_heat * 0.25 / days_since_created)

s/days_since_created/days_since_last_activity

> +
> + return int(total_heat)

Similarly in the test:

> + expected = int((fresh_heat * (0.99 ** 10)) + (100 * 0.25 / 20))
s/20/10

{{{
14:17 < noodles775> intellectronica: I can't see that days_since_last_activity is being used for anything?
14:18 < noodles775> Did you mean to do (max_heat * 0.25 / (days_since_created - days_since_last_activity)) or something similar, looking at the comment?
14:19 < noodles775> Ah, or looking at the related bug title, I'm guessing it should be s/dasy_since_created/days_since_last_activity on line 21 on the MP diff?
14:21 < intellectronica> noodles775: no, i think that's a cut-n-paste error.
14:27 < noodles775> intellectronica: so should it be divided by the number of days *since* the bugs last activity (as stated in the bug title), or divided by the difference between the days since the bug was created and it's last activity (as the comment seems to suggest?)
14:28 < intellectronica> noodles775: it should be divided by the days since the bug's creation
14:28 < noodles775> intellectronica: so the bug 567439 title is wrong then, ok.
14:28 < mup> Bug #567439: Add MAX_HEAT / 4 / days since last activity to bug heat <story-bug-heat> <Launchpad Bugs:In Progress by intellectronica> <https://launchpad.net/bugs/567439>
14:29 < intellectronica> noodles775: oh, right, it is. there's another bug for a calculation based on time since last activity, i must have confused them.
}}}

review: Approve (code)

« Back to merge proposal