Merge lp:~mvo/software-center/exact-match-duplication-lp891613 into lp:software-center

Proposed by Michael Vogt
Status: Merged
Merged at revision: 3207
Proposed branch: lp:~mvo/software-center/exact-match-duplication-lp891613
Merge into: lp:software-center
Diff against target: 96 lines (+58/-0)
3 files modified
softwarecenter/db/enquire.py (+12/-0)
softwarecenter/db/update.py (+6/-0)
tests/test_database.py (+40/-0)
To merge this branch: bzr merge lp:~mvo/software-center/exact-match-duplication-lp891613
Reviewer Review Type Date Requested Status
Gary Lasker (community) Approve
Review via email: mp+126902@code.launchpad.net

Description of the change

This branch fixes the duplication of packages if there is a exact pkgname
match in the apt-xapian-index and also in the software-center-agent.

Skype is a example for this when the extras.ubuntu.com repository is
enabled.

To post a comment you must log in.
Revision history for this message
Gary Lasker (gary-lasker) wrote :

Hi Michael, thanks for this branch. This is definitely an improvement as it does indeed show only a single entry now for e.g. Skype and Fogger by default when searching those package names.

In testing, however, I'm noticing a strange side effect and I wanted to get your take on it. When searching for e.g. "lightread", notice that there's a "Show -1 technical items" link at the bottom of the window:

  http://ubuntuone.com/2obsheSDCDcqQM2ZMdUymB

First of all, I've never noticed a "-1" in that link before.

Secondly, if I click the link, I see the "hidden" duplicate package, as per bug 1043159:

  http://ubuntuone.com/1GL1XyNKIhNJYqTtHpEYun

Can you reproduce this as well?

Revision history for this message
Gary Lasker (gary-lasker) wrote :

Please also note that this symptom occurs after merging the follow-on branch lp:~mvo/software-center/de-duplication-multiple-pkgnames-lp1043159 as well. Thanks again!

3208. By Michael Vogt

softwarecenter/db/enquire.py: address review comment from gary to fix technical item counting

Revision history for this message
Michael Vogt (mvo) wrote :

On Sun, Sep 30, 2012 at 11:40:29PM -0000, Gary Lasker wrote:
> Hi Michael, thanks for this branch. This is definitely an improvement as it does indeed show only a single entry now for e.g. Skype and Fogger by default when searching those package names.
>
> In testing, however, I'm noticing a strange side effect and I wanted to get your take on it. When searching for e.g. "lightread", notice that there's a "Show -1 technical items" link at the bottom of the window:
>
> http://ubuntuone.com/2obsheSDCDcqQM2ZMdUymB
>
> First of all, I've never noticed a "-1" in that link before.
>
> Secondly, if I click the link, I see the "hidden" duplicate package, as per bug 1043159:
>
> http://ubuntuone.com/1GL1XyNKIhNJYqTtHpEYun
>
> Can you reproduce this as well?

Thanks for noticing this. This is now fixed in r3208.

Cheers,
 Michael

Revision history for this message
Gary Lasker (gary-lasker) wrote :

Thank you, Michael, all good now!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'softwarecenter/db/enquire.py'
2--- softwarecenter/db/enquire.py 2012-09-27 13:02:26 +0000
3+++ softwarecenter/db/enquire.py 2012-10-01 07:20:33 +0000
4@@ -155,6 +155,18 @@
5 exact_pkgname_query = (len(terms) == 1 and
6 terms[0].startswith("XP"))
7
8+ # see if we should do a app query and skip the pkg query
9+ # see bug #891613 and #1043159
10+ if exact_pkgname_query:
11+ with ExecutionTime("de-duplication"):
12+ q_app = xapian.Query(terms[0].replace("XP", "AP"))
13+ nr_apps, nr_pkgs = self._get_estimate_nr_apps_and_nr_pkgs(
14+ enquire, q_app, xfilter)
15+ if nr_apps == 1:
16+ q = q_app
17+ # this is a app query now
18+ exact_pkgname_query = False
19+
20 with ExecutionTime("calculate nr_apps and nr_pkgs: "):
21 nr_apps, nr_pkgs = self._get_estimate_nr_apps_and_nr_pkgs(
22 enquire, q, xfilter)
23
24=== modified file 'softwarecenter/db/update.py'
25--- softwarecenter/db/update.py 2012-09-27 13:02:26 +0000
26+++ softwarecenter/db/update.py 2012-10-01 07:20:33 +0000
27@@ -699,12 +699,18 @@
28 AppInfoFields.SUMMARY: 'description',
29 }
30
31+ STATIC_DATA = {
32+ AppInfoFields.TYPE: 'Application',
33+ }
34+
35 def __init__(self, tag_section, url):
36 super(JsonTagSectionParser, self).__init__()
37 self.tag_section = tag_section
38 self.url = url
39
40 def get_value(self, key, translated=True):
41+ if key in self.STATIC_DATA:
42+ return self.STATIC_DATA[key]
43 return self.tag_section.get(self._apply_mapping(key))
44
45 @property
46
47=== modified file 'tests/test_database.py'
48--- tests/test_database.py 2012-09-18 09:21:16 +0000
49+++ tests/test_database.py 2012-10-01 07:20:33 +0000
50@@ -853,6 +853,46 @@
51 self.assertTrue(db._on_axi_stamp_changed.called)
52
53
54+
55+class DBSearchTestCase(unittest.TestCase):
56+
57+ APP_INFO_JSON="""
58+[
59+ {
60+ "application_name": "The apt",
61+ "package_name": "apt",
62+ "description": "meep"
63+ }
64+]
65+"""
66+
67+ def test_search_app_pkgname_duplication_lp891613(self):
68+ # create a fake database to simualte a run of software-center-agent
69+ cache = get_pkg_info()
70+ cache.open()
71+ db = xapian.WritableDatabase(TEST_DB,
72+ xapian.DB_CREATE_OR_OVERWRITE)
73+ res = update_from_json_string(
74+ db, cache, self.APP_INFO_JSON, origin="local")
75+ db.close()
76+ self.assertTrue(res)
77+ # create a StoreDatabase and add our other db
78+ db = get_test_db()
79+ db.add_database(xapian.Database(TEST_DB))
80+ db.open(use_axi=True)
81+ enquire = AppEnquire(db._aptcache, db)
82+ # simulate a pkg "apt" that is both in the agent and in the x-a-i db
83+ search_term = "apt"
84+ search_query = db.get_query_list_from_search_entry(search_term)
85+ enquire.set_query(search_query, nonblocking_load=False)
86+ self.assertTrue(len(enquire._matches) > 2)
87+ for m in enquire._matches:
88+ doc = m.document
89+ # ensure that all hits are "apps" and do not come from a-x-i
90+ self.assertNotEqual(
91+ doc.get_value(XapianValues.PKGNAME), "")
92+
93+
94 if __name__ == "__main__":
95 #import logging
96 #logging.basicConfig(level=logging.DEBUG)

Subscribers

People subscribed via source and target branches