Merge lp:~mvo/software-center/whats-new-lp1044033 into lp:software-center

Proposed by Michael Vogt on 2012-09-27
Status: Merged
Merged at revision: 3206
Proposed branch: lp:~mvo/software-center/whats-new-lp1044033
Merge into: lp:software-center
Diff against target: 149 lines (+32/-43)
5 files modified
softwarecenter/db/categories.py (+2/-10)
softwarecenter/db/enquire.py (+5/-4)
softwarecenter/db/update.py (+11/-6)
softwarecenter/enums.py (+3/-0)
tests/gtk3/test_catview.py (+11/-23)
To merge this branch: bzr merge lp:~mvo/software-center/whats-new-lp1044033
Reviewer Review Type Date Requested Status
Gary Lasker (community) 2012-09-27 Approve on 2012-09-28
Review via email: mp+126680@code.launchpad.net

Description of the change

This branch ensures that there is a fallback xapian value that can be
used if the apt-xapian-index has not been created.

This will improve the first-run experience. There will be a sorted
(by publication time) whats-new when update-software-center-agent
finished its first run. Until that run is finished the list will be
in random order.

To post a comment you must log in.
3206. By Michael Vogt on 2012-09-27

trivial pyflakes fix

Gary Lasker (gary-lasker) wrote :

This is great, thanks, Michael!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'softwarecenter/db/categories.py'
2--- softwarecenter/db/categories.py 2012-09-17 10:33:16 +0000
3+++ softwarecenter/db/categories.py 2012-09-27 13:18:21 +0000
4@@ -502,17 +502,9 @@
5 if sortmode in (SortMethods.UNSORTED,
6 SortMethods.BY_ALPHABET,
7 SortMethods.BY_TOP_RATED,
8- SortMethods.BY_SEARCH_RANKING):
9+ SortMethods.BY_SEARCH_RANKING,
10+ SortMethods.BY_CATALOGED_TIME):
11 return True
12- # only supported with a apt-xapian-index version that has the
13- # "catalogedtime" value
14- elif sortmode == SortMethods.BY_CATALOGED_TIME:
15- if self.db._axi_values and "catalogedtime" in self.db._axi_values:
16- return True
17- else:
18- LOG.warn("sort by cataloged time requested but your a-x-i "
19- "does not seem to support that yet")
20- return False
21 # we don't know this sortmode
22 LOG.error("unknown sort mode '%i'" % sortmode)
23 return False
24
25=== modified file 'softwarecenter/db/enquire.py'
26--- softwarecenter/db/enquire.py 2012-03-15 04:30:04 +0000
27+++ softwarecenter/db/enquire.py 2012-09-27 13:18:21 +0000
28@@ -179,12 +179,13 @@
29
30 # cataloged time - what's new category
31 if self.sortmode == SortMethods.BY_CATALOGED_TIME:
32+ sorter = xapian.MultiValueKeyMaker()
33 if (self.db._axi_values and
34 "catalogedtime" in self.db._axi_values):
35- enquire.set_sort_by_value(
36- self.db._axi_values["catalogedtime"], reverse=True)
37- else:
38- LOG.warning("no catelogedtime in axi")
39+ sorter.add_value(
40+ self.db._axi_values["catalogedtime"])
41+ sorter.add_value(XapianValues.DB_CATALOGED_TIME)
42+ enquire.set_sort_by_key(sorter, reverse=True)
43 elif self.sortmode == SortMethods.BY_TOP_RATED:
44 from softwarecenter.backend.reviews import get_review_loader
45 review_loader = get_review_loader(self.cache, self.db)
46
47=== modified file 'softwarecenter/db/update.py'
48--- softwarecenter/db/update.py 2012-09-17 23:50:24 +0000
49+++ softwarecenter/db/update.py 2012-09-27 13:18:21 +0000
50@@ -351,16 +351,21 @@
51 self._set_doc_from_key(doc, field)
52
53 # date published
54- date_published = self._set_doc_from_key(doc,
55- AppInfoFields.DATE_PUBLISHED)
56+ date_published_str = self._set_doc_from_key(
57+ doc, AppInfoFields.DATE_PUBLISHED)
58 # we use the date published value for the cataloged time as well
59- if date_published is not None and "catalogedtime" in axi_values:
60+ if date_published_str is not None:
61 LOG.debug("pkgname: %s, date_published cataloged time is: %s",
62- pkgname, date_published)
63- date_published = time.mktime(time.strptime(date_published,
64+ pkgname, date_published_str)
65+ date_published = time.mktime(time.strptime(date_published_str,
66 "%Y-%m-%d %H:%M:%S"))
67- doc.add_value(axi_values["catalogedtime"],
68+ # a value for our own DB
69+ doc.add_value(XapianValues.DB_CATALOGED_TIME,
70 xapian.sortable_serialise(date_published))
71+ if "catalogedtime" in axi_values:
72+ # compat with a-x-i
73+ doc.add_value(axi_values["catalogedtime"],
74+ xapian.sortable_serialise(date_published))
75
76 # icon (for third party)
77 url = self._set_doc_from_key(doc, AppInfoFields.ICON_URL)
78
79=== modified file 'softwarecenter/enums.py'
80--- softwarecenter/enums.py 2012-09-17 23:50:24 +0000
81+++ softwarecenter/enums.py 2012-09-27 13:18:21 +0000
82@@ -167,6 +167,9 @@
83 SC_SUPPORTED_DISTROS = 199
84 WEBSITE = 200
85 CURRENCY = 201
86+ # this is used to provide a cataloged time if there is no a-x-i in use
87+ # or if a-x-i is not available yet
88+ DB_CATALOGED_TIME = 202
89
90
91 class AppInfoFields:
92
93=== modified file 'tests/gtk3/test_catview.py'
94--- tests/gtk3/test_catview.py 2012-09-24 08:22:54 +0000
95+++ tests/gtk3/test_catview.py 2012-09-27 13:18:21 +0000
96@@ -1,6 +1,5 @@
97 import unittest
98
99-from gi.repository import Gtk
100 from mock import patch, Mock
101
102 from tests.utils import (
103@@ -76,35 +75,24 @@
104 self.assertEqual(self._cat.name, 'What\xe2\x80\x99s New')
105 self.assertEqual(self._cat.sortmode, SortMethods.BY_CATALOGED_TIME)
106
107- def test_new_no_sort_info_yet(self):
108- # ensure that we don't show a empty "whats new" category
109- # see LP: #865985
110+ def test_no_axi_cataloged_time_info_yet(self):
111+ """ ensure that we show "whats new" DB_CATALOGED_TIME data if there
112+ is no x-a-i yet """
113 db = get_test_db()
114 cache = db._aptcache
115- # simulate a fresh install with no catalogedtime info
116- del db._axi_values["catalogedtime"]
117-
118 icons = get_test_gtk3_icon_cache()
119-
120 apps_filter = AppFilter(db, cache)
121
122+ # simulate a fresh install with no catalogedtime info in a-x-i
123+ if "catalogedtime" in db._axi_values:
124+ del db._axi_values["catalogedtime"]
125+
126+ # create it
127 view = lobbyview.LobbyView(cache, db, icons,
128 softwarecenter.distro.get_distro(), apps_filter)
129- view.show()
130-
131- # gui
132- win = Gtk.Window()
133- self.addCleanup(win.destroy)
134- win.set_size_request(800, 400)
135-
136- scroll = Gtk.ScrolledWindow()
137- scroll.add(view)
138- scroll.show()
139- win.add(scroll)
140- win.show()
141- # test visibility
142- do_events()
143- self.assertFalse(view.whats_new_frame.get_property("visible"))
144+ view.show_all()
145+ # and ensure its visible
146+ self.assertTrue(view.whats_new_frame.get_property("visible"))
147
148
149 class RecommendationsTestCase(CatViewBaseTestCase):

Subscribers

People subscribed via source and target branches