Merge lp:~thumper/launchpad/revision-karma-fix into lp:launchpad
| Status: | Merged | ||||
|---|---|---|---|---|---|
| Approved by: | Tim Penhey on 2010-01-05 | ||||
| Approved revision: | not available | ||||
| Merged at revision: | 10105 | ||||
| Proposed branch: | lp:~thumper/launchpad/revision-karma-fix | ||||
| Merge into: | lp:launchpad | ||||
| Diff against target: |
279 lines (+78/-31) 8 files modified
lib/lp/code/interfaces/branchtarget.py (+1/-1) lib/lp/code/model/branchtarget.py (+9/-6) lib/lp/code/model/revision.py (+9/-9) lib/lp/code/model/tests/test_revision.py (+44/-9) lib/lp/code/scripts/revisionkarma.py (+3/-2) lib/lp/registry/interfaces/person.py (+4/-1) lib/lp/registry/model/person.py (+5/-2) lib/lp/testing/factory.py (+3/-1) |
||||
| To merge this branch: | bzr merge lp:~thumper/launchpad/revision-karma-fix | ||||
| Related bugs: |
|
| Reviewer | Review Type | Date Requested | Status |
|---|---|---|---|
| Jonathan Lange (community) | Needs Fixing on 2010-01-05 | ||
| Michael Hudson-Doyle | 2010-01-05 | Approve on 2010-01-05 | |
|
Review via email:
|
|||
Commit Message
Fix the allocation of karma for revisions
| Tim Penhey (thumper) wrote : | # |
| Michael Hudson-Doyle (mwhudson) wrote : | # |
Generally, I like the changes.
> === modified file 'lib/lp/
> --- lib/lp/
> +++ lib/lp/
> @@ -86,10 +86,8 @@
> """See `IRevision`."""
> # If we know who the revision author is, give them karma.
> author = self.revision_
> - if (author is not None and branch.product is not None):
> - # No karma for junk branches as we need a product to link
> - # against.
> - karma = author.
> + if (author is not None):
These parens can go now.
> + karma = branch.
> # Backdate the karma to the time the revision was created. If the
> # revision_date on the revision is in future (for whatever weird
> # reason) we will use the date_created from the revision (which
> @@ -98,8 +96,12 @@
> # is lying), and a problem with the way the Launchpad code
> # currently does its karma degradation over time.
> if karma is not None:
> - karma.datecreated = min(self.
> + removeSecurityP
> + self.revision_date, self.date_created)
> self.karma_
> + return karma
> + else:
> + return None
>
> def getBranch(self, allow_private=
> """See `IRevision`."""
> @@ -385,9 +387,6 @@
> from lp.registry.
>
> store = getUtility(
> -
> - # XXX: Tim Penhey 2008-08-12, bug 244768
> - # Using Not(column == None) rather than column != None.
> return store.find(
> Revision,
> Revision.
> @@ -397,7 +396,8 @@
> Select(True,
> And(BranchRevis
> BranchRevision.
> - Not(Branch.product == None)),
> + Or(Branch.product != None,
> + Branch.distroseries != None)),
> (Branch, BranchRevision))))
>
> @staticmethod
> === modified file 'lib/lp/
> --- lib/lp/
> +++ lib/lp/
> @@ -39,8 +39,9 @@
> count = 0
> revision_set = getUtility(
> # Break into bits.
> - revisions = list(
> - revision_
> + result_set = revision_
> + self.logger.
> + revisions = list(result_
> while len(revisions) > 0:
> for revision in revisions:
> # Find t...
| Jonathan Lange (jml) wrote : | # |
> === modified file 'lib/lp/
> --- lib/lp/
> +++ lib/lp/
...
> @@ -98,8 +96,12 @@
> # is lying), and a problem with the way the Launchpad code
> # currently does its karma degradation over time.
> if karma is not None:
> - karma.datecreated = min(self.
> + removeSecurityP
> + self.revision_date, self.date_created)
> self.karma_
> + return karma
> + else:
> + return None
>
Like Michael, I generally like the changes. However, I'm pretty sure we should avoid using removeSecurityProxy in model code. If we have no other choice, then we should at least have a comment explaining why.

The revision allocation script has been broken for a little while. It gets itself into an infinite loop. I have had the LOSAs kill it for now.
The fundamental problem was someone fixing Revision.getBranch to be source package aware. Unfortunately the allocation of karma wasn't, and so as soon as a revision that was in a product branch (which is what the query checked for) but the Revision.getBranch returned a package branch, the script got in a loop.
This branch has the following fixes: makeRevision can now take a Person for the author, and will use that person's email address
* factory.
* the revision karma allocation script logs at the start of the run how many revisions it thinks it needs to allocate karma for
* getting revision needing karma allocated now check for related package branches
* the actual karma allocation is done by the branch target, and the method returns the karma object