I am not using a set, since Language.translators is already sorted by karma (done in a single SQL query).
Using a set and then resorting it at the end will require a new SQL query for each person.
KarmaCache can not be updated from the „browser” layer and we need a unit test for services.worlddata.model.language.Language.translators running in LaunchpadZopelessLayer.
I have extended the current Language.translators karma text code to check that translators for a language are sorted according to their karma value.
Here is the latest diff:
=== modified file 'lib/lp/services/worlddata/doc/language.txt'
--- lib/lp/services/worlddata/doc/language.txt 2010-04-15 11:53:11 +0000
+++ lib/lp/services/worlddata/doc/language.txt 2010-04-21 00:06:25 +0000
@@ -273,8 +273,14 @@
To be considered a translator, they must have done some translations and
have the language among their preferred languages.
-The top contributors are listed on the language page, and for merged account
+The top contributors are listed on the language page, and for a merged account
we will see their targed account.
Create some translators and a merged account.
@@ -169,6 +169,7 @@
I am not using a set, since Language. translators is already sorted by karma (done in a single SQL query).
Using a set and then resorting it at the end will require a new SQL query for each person.
KarmaCache can not be updated from the „browser” layer and we need a unit test for services. worlddata. model.language. Language. translators running in LaunchpadZopele ssLayer.
I have extended the current Language. translators karma text code to check that translators for a language are sorted according to their karma value.
Here is the latest diff:
=== modified file 'lib/lp/ services/ worlddata/ doc/language. txt' services/ worlddata/ doc/language. txt 2010-04-15 11:53:11 +0000 services/ worlddata/ doc/language. txt 2010-04-21 00:06:25 +0000
--- lib/lp/
+++ lib/lp/
@@ -273,8 +273,14 @@
To be considered a translator, they must have done some translations and
have the language among their preferred languages.
- >>> translator = factory. makePerson( name=u' serbian- translator' ) addLanguage( sr) makePerson( name=u' serbian- translator- karma-10' ) 10.addLanguage( sr) makePerson( name=u' serbian- translator- karma-20' ) 20.addLanguage( sr) makePerson( name=u' serbian- translator- karma-30' ) 30.addLanguage( sr) makePerson( name=u' serbian- translator- karma-40' ) 40.addLanguage( sr) ssLayer ssLayer. commit( )
- >>> translator.
+ >>> translator_10 = factory.
+ >>> translator_
+ >>> translator_20 = factory.
+ >>> translator_
+ >>> translator_30 = factory.
+ >>> translator_
+ >>> translator_40 = factory.
+ >>> translator_
>>> from canonical.testing import LaunchpadZopele
>>> LaunchpadZopele
@@ -283,13 +289,26 @@ ssLayer. switchDbUser( 'karma' ) category = KarmaCategory. selectOne( name==' translations' ) person= translator, translations_ category, person= translator_ 30, translations_ category, person= translator_ 10, translations_ category, person= translator_ 20, translations_ category, person= translator_ 40, translations_ category, ssLayer. commit( ) ssLayer. switchDbUser( 'launchpad' ) translator' ] translator- karma-40 translator- karma-30 translator- karma-20 translator- karma-10
>>> LaunchpadZopele
>>> translations_
... KarmaCategory.
- >>> karma = KarmaCache(
- ... category=
- ... karmavalue=1)
+ >>> karma = KarmaCache(
+ ... category=
+ ... karmavalue=30)
+ >>> karma = KarmaCache(
+ ... category=
+ ... karmavalue=10)
+ >>> karma = KarmaCache(
+ ... category=
+ ... karmavalue=20)
+ >>> karma = KarmaCache(
+ ... category=
+ ... karmavalue=40)
>>> LaunchpadZopele
>>> LaunchpadZopele
- >>> [translator.name for translator in sr.translators]
- [u'serbian-
+ >>> for translator in sr.translators:
+ ... print translator.name
+ serbian-
+ serbian-
+ serbian-
+ serbian-
=========
=== modified file 'lib/lp/ translations/ browser/ tests/language- views.txt' translations/ browser/ tests/language- views.txt 2010-04-17 17:40:26 +0000 translations/ browser/ tests/language- views.txt 2010-04-20 23:53:54 +0000
--- lib/lp/
+++ lib/lp/
@@ -106,7 +106,7 @@
1 : 2, 3, 4, 22, 23, 24...
2 : 0, 5, 6, 7, 8, 9...
-The top contributors are listed on the language page, and for merged account
+The top contributors are listed on the language page, and for a merged account
we will see their targed account.
Create some translators and a merged account.
@@ -169,6 +169,7 @@
>>> Language. translators = translators_method
+
View LanguageSet
------------------