Merge lp://staging/~adiroiban/launchpad/bug-564852 into lp://staging/launchpad
Status: | Merged | ||||
---|---|---|---|---|---|
Approved by: | Brad Crittenden | ||||
Approved revision: | no longer in the source branch. | ||||
Merged at revision: | not available | ||||
Proposed branch: | lp://staging/~adiroiban/launchpad/bug-564852 | ||||
Merge into: | lp://staging/launchpad | ||||
Diff against target: |
181 lines (+50/-20) 4 files modified
lib/lp/services/worlddata/doc/language.txt (+26/-7) lib/lp/translations/browser/language.py (+9/-7) lib/lp/translations/browser/tests/language-views.txt (+14/-5) lib/lp/translations/templates/language-portlet-top-contributors.pt (+1/-1) |
||||
To merge this branch: | bzr merge lp://staging/~adiroiban/launchpad/bug-564852 | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Brad Crittenden (community) | code | Approve | |
Review via email: mp+23612@code.staging.launchpad.net |
Commit message
Sort the top language contributors according to their karma value. Greatest karma should be listed first.
Description of the change
= Bug 564852 =
Example: https:/
The list shows those people with the lowest karma instead of those with the highest. Not really important, but might be easy to fix if it’s just the ordering …
== Proposed fix ==
The list should contain contributors with greatest karma.
== Pre-implementation notes ==
Danilo added a comment on the bug report telling that it is OK if the list will contain less that 20 contributors and in this case we can use slicing to improve performance.
== Implementation details ==
Since we can no longer guarantee that the list will contain 20 items, I have removed all references to „top 20”.
From the SQL result, I'm getting the top 30 items so that in the case some top accounts are merged account of the rest top accounts there will increase the probability of having 20 items in the list.
I don't know how to fix the make lint import errors. Is there a wiki page explaining how to fix those errors?
== Tests ==
lp-test language-views
== Demo and Q/A ==
Since top language contributors depends on karma values that are generated using cronscript it is not easy to demo this feature.
= Launchpad lint =
Checking for conflicts. and issues in doctests and templates.
Running jslint, xmllint, pyflakes, and pylint.
Using normal rules.
Linting changed files:
lib/lp/
lib/lp/
lib/lp/
== Pylint notices ==
lib/lp/
24: [F0401] Unable to import 'canonical.
25: [F0401] Unable to import 'canonical.
26: [F0401] Unable to import 'canonical.
30: [F0401] Unable to import 'canonical.
31: [F0401] Unable to import 'canonical.
32: [F0401] Unable to import 'lp.services.
33: [F0401] Unable to import 'lp.translation
35: [F0401] Unable to import 'lp.translation
36: [F0401] Unable to import 'lp.translation
38: [F0401] Unable to import 'canonical.widgets' (No module named canonical.widgets)
Hi Adi,
Thanks for the branch. I have a few minor corrections and a request for better test coverage.
When this branch is complete I'll be happy to land it for you.
Thanks,
Brad
> === modified file 'lib/lp/ translations/ browser/ language. py' translations/ browser/ language. py 2010-03-02 12:04:59 +0000 s(self) : list(self. context. translators) ):
> --- lib/lp/
> @@ -216,15 +218,15 @@
> @property
> def top_contributor
> """
> - Get the top 20 contributors for a language.
> + Get the top contributors for a language.
>
> If an account has been merged, the account into which it was
> merged will be returned.
> """
> - translators = []
> - for translator in reversed(
> + top_translators = []
If you use a set...
> + for translator in self.context. translators[ :30]: translators) >= 20): append( translator_ target) .append( translator_ target)
> # Get only the top 20 contributors
> - if (len(translators) >= 20):
> + if (len(top_
> break
>
> # For merged account add the target account
> @@ -235,10 +237,10 @@
>
> # Add translator only if it was not previouly added as a
> # merged account
> - if translator_target not in translators:
> - translators.
> + if translator_target not in top_translators:
> + top_translators
You can avoid the test here and just add it.
> plural_ forms(self) : '+addquestion' ,
> - return translators
> + return top_translators
>
> @property
> def friendly_
> @@ -268,6 +270,7 @@
> view_name=
> rootsite='answers')
>
> === modified file 'lib/lp/ translations/ browser/ tests/language- views.txt' translations/ browser/ tests/language- views.txt 2010-03-16 01:04:05 +0000 translations/ browser/ tests/language- views.txt 2010-04-17 17:46:16 +0000
> --- lib/lp/
> +++ lib/lp/
> @@ -106,17 +106,13 @@
> 1 : 2, 3, 4, 22, 23, 24...
> 2 : 0, 5, 6, 7, 8, 9...
>
> -The top 20 contributors are listed on the language page, and for merged account
> +The top contributors are listed on the language page, and for
> merged account
typo: and for a merged
> we will see their targed account. append( factory. makePerson( 'Translator No.' + str(translator_ nr))) r-main' , 'Translator Main') 'Translator Merged')) append( translator_ merged) merged. merged = translator_main append( factory. makePerson( 'Translator No.' + str(transla...
>
> Create some translators and a merged account.
>
> >>> from zope.security.proxy import removeSecurityProxy
> >>> translators = []
> - >>> for translator_nr in range(22):
> - ... translators.
> - ... name='translator-' + str(translator_nr),
> - ... displayname=
> >>> translator_main = factory.makePerson(
> ... name='translato
> ... displayname=
> @@ -126,6 +122,10 @@
> ... displayname=
> >>> translators.
> >>> translator_
> + >>> for translator_nr in range(22):
> + ... translators.
> + ... name='translator-' + str(translator_nr),
> + ... displayname=