← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~wgrant/launchpad/lets-try-sorting-again into lp:launchpad

 

William Grant has proposed merging lp:~wgrant/launchpad/lets-try-sorting-again into lp:launchpad.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)
Related bugs:
  Bug #797820 in Launchpad itself: "searching for the last name makes still hard to find the person"
  https://bugs.launchpad.net/launchpad/+bug/797820
  Bug #800043 in Launchpad itself: "IRC nickname search in person picker is case-sensitive"
  https://bugs.launchpad.net/launchpad/+bug/800043

For more details, see:
https://code.launchpad.net/~wgrant/launchpad/lets-try-sorting-again/+merge/65308

And so it continues -- another push at the person picker prominence problem.

name and displayname and emailaddress matches are currently up to 10x the value of a reasonable FTI match. This results in problems as seen in bug #797820, where even highly karma-boosted FTI results are unable to get past the prefix matches. This branch drags them back down to around the middle of the FTI matches, so karma boosting can get the relevant results to the top. The precise values don't matter terribly much, as karma normally makes a good discriminator -- the main thing is to get them to the same order of magnitude.

I've tested this on dogfood's DB, and it seems to work OK for all LP and Ubuntu cases I've tried, including the one mentioned in the bug.

The second change is just to make IRC nickname matching case-insensitive. I discovered it was case-sensitive when searching for "scottk" didn't find ScottK, which seems unintuitive.
-- 
https://code.launchpad.net/~wgrant/launchpad/lets-try-sorting-again/+merge/65308
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~wgrant/launchpad/lets-try-sorting-again into lp:launchpad.
=== modified file 'lib/canonical/launchpad/doc/vocabulary-json.txt'
--- lib/canonical/launchpad/doc/vocabulary-json.txt	2011-06-03 12:59:31 +0000
+++ lib/canonical/launchpad/doc/vocabulary-json.txt	2011-06-21 07:22:36 +0000
@@ -87,13 +87,13 @@
     {
         "entries": [
             {
-                "alt_title": "admins",
-                "alt_title_link": "http://launchpad.dev/~admins";,
-                "api_uri": "/~admins",
+                "alt_title": "commercial-admins",
+                "alt_title_link": "http://launchpad.dev/~commercial-admins";,
+                "api_uri": "/~commercial-admins",
                 "css": "sprite team",
                 "link_css": "js-action",
-                "title": "Launchpad Administrators",
-                "value": "admins"
+                "title": "Commercial Subscription Admins",
+                "value": "commercial-admins"
             }
         ],
         "total_size": 6
@@ -106,14 +106,14 @@
     {
         "entries": [
             {
-                "alt_title": "name16",
-                "alt_title_link": "http://launchpad.dev/~name16";,
-                "api_uri": "/~name16",
-                "css": "sprite person",
-                "description": "<email address hidden>",
+                "alt_title": "launchpad-buildd-admins",
+                "alt_title_link":
+                    "http://launchpad.dev/~launchpad-buildd-admins";,
+                "api_uri": "/~launchpad-buildd-admins",
+                "css": "sprite team",
                 "link_css": "js-action",
-                "title": "Foo Bar",
-                "value": "name16"
+                "title": "Launchpad Buildd Admins",
+                "value": "launchpad-buildd-admins"
             }
         ],
         "total_size": 6

=== modified file 'lib/lp/registry/tests/test_person_vocabularies.py'
--- lib/lp/registry/tests/test_person_vocabularies.py	2011-06-14 02:39:43 +0000
+++ lib/lp/registry/tests/test_person_vocabularies.py	2011-06-21 07:22:36 +0000
@@ -130,6 +130,14 @@
     def test_root_karma_context(self):
         self.assertKarmaContextConstraint(None, None)
 
+    def test_irc_nick_match_is_not_case_sensitive(self):
+        person = self.factory.makePerson()
+        irc = getUtility(IIrcIDSet).new(
+            person, 'somenet', 'MiXeD' + self.factory.getUniqueString())
+        with FeatureFixture(PERSON_AFFILIATION_RANK_FLAG):
+            self.assertContentEqual(
+                [person], self.searchVocabulary(person, irc.nickname.lower()))
+
 
 class TestValidPersonOrTeamPreloading(VocabularyTestBase,
                                       TestCaseWithFactory):

=== modified file 'lib/lp/registry/vocabularies.py'
--- lib/lp/registry/vocabularies.py	2011-06-16 16:28:28 +0000
+++ lib/lp/registry/vocabularies.py	2011-06-21 07:22:36 +0000
@@ -748,8 +748,8 @@
                     SELECT Person.id,
                     (case
                         when person.name=? then 100
-                        when person.name like ? || '%%' then 5
-                        when lower(person.displayname) like ? || '%%' then 4
+                        when person.name like ? || '%%' then 0.6
+                        when lower(person.displayname) like ? || '%%' then 0.5
                         else rank(fti, ftq(?))
                     end) as rank
                     FROM Person
@@ -757,12 +757,12 @@
                     or lower(Person.displayname) LIKE ? || '%%'
                     or Person.fti @@ ftq(?)
                     UNION ALL
-                    SELECT Person.id, 3 AS rank
+                    SELECT Person.id, 0.8 AS rank
                     FROM Person, IrcID
                     WHERE Person.id = IrcID.person
-                        AND IrcID.nickname = ?
+                        AND LOWER(IrcID.nickname) = LOWER(?)
                     UNION ALL
-                    SELECT Person.id, 2 AS rank
+                    SELECT Person.id, 0.4 AS rank
                     FROM Person, EmailAddress
                     WHERE Person.id = EmailAddress.person
                         AND LOWER(EmailAddress.email) LIKE ? || '%%'
@@ -779,8 +779,8 @@
                 private_ranking_sql = SQL("""
                     (case
                         when person.name=? then 100
-                        when person.name like ? || '%%' then 5
-                        when lower(person.displayname) like ? || '%%' then 3
+                        when person.name like ? || '%%' then 0.6
+                        when lower(person.displayname) like ? || '%%' then 0.5
                         else rank(fti, ftq(?))
                     end) as rank
                 """, (text, text, text, text))