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

Proposed by Michael Vogt
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) Approve
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

trivial pyflakes fix

Revision history for this message
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
=== modified file 'softwarecenter/db/categories.py'
--- softwarecenter/db/categories.py 2012-09-17 10:33:16 +0000
+++ softwarecenter/db/categories.py 2012-09-27 13:18:21 +0000
@@ -502,17 +502,9 @@
502 if sortmode in (SortMethods.UNSORTED,502 if sortmode in (SortMethods.UNSORTED,
503 SortMethods.BY_ALPHABET,503 SortMethods.BY_ALPHABET,
504 SortMethods.BY_TOP_RATED,504 SortMethods.BY_TOP_RATED,
505 SortMethods.BY_SEARCH_RANKING):505 SortMethods.BY_SEARCH_RANKING,
506 SortMethods.BY_CATALOGED_TIME):
506 return True507 return True
507 # only supported with a apt-xapian-index version that has the
508 # "catalogedtime" value
509 elif sortmode == SortMethods.BY_CATALOGED_TIME:
510 if self.db._axi_values and "catalogedtime" in self.db._axi_values:
511 return True
512 else:
513 LOG.warn("sort by cataloged time requested but your a-x-i "
514 "does not seem to support that yet")
515 return False
516 # we don't know this sortmode508 # we don't know this sortmode
517 LOG.error("unknown sort mode '%i'" % sortmode)509 LOG.error("unknown sort mode '%i'" % sortmode)
518 return False510 return False
519511
=== modified file 'softwarecenter/db/enquire.py'
--- softwarecenter/db/enquire.py 2012-03-15 04:30:04 +0000
+++ softwarecenter/db/enquire.py 2012-09-27 13:18:21 +0000
@@ -179,12 +179,13 @@
179179
180 # cataloged time - what's new category180 # cataloged time - what's new category
181 if self.sortmode == SortMethods.BY_CATALOGED_TIME:181 if self.sortmode == SortMethods.BY_CATALOGED_TIME:
182 sorter = xapian.MultiValueKeyMaker()
182 if (self.db._axi_values and183 if (self.db._axi_values and
183 "catalogedtime" in self.db._axi_values):184 "catalogedtime" in self.db._axi_values):
184 enquire.set_sort_by_value(185 sorter.add_value(
185 self.db._axi_values["catalogedtime"], reverse=True)186 self.db._axi_values["catalogedtime"])
186 else:187 sorter.add_value(XapianValues.DB_CATALOGED_TIME)
187 LOG.warning("no catelogedtime in axi")188 enquire.set_sort_by_key(sorter, reverse=True)
188 elif self.sortmode == SortMethods.BY_TOP_RATED:189 elif self.sortmode == SortMethods.BY_TOP_RATED:
189 from softwarecenter.backend.reviews import get_review_loader190 from softwarecenter.backend.reviews import get_review_loader
190 review_loader = get_review_loader(self.cache, self.db)191 review_loader = get_review_loader(self.cache, self.db)
191192
=== modified file 'softwarecenter/db/update.py'
--- softwarecenter/db/update.py 2012-09-17 23:50:24 +0000
+++ softwarecenter/db/update.py 2012-09-27 13:18:21 +0000
@@ -351,16 +351,21 @@
351 self._set_doc_from_key(doc, field)351 self._set_doc_from_key(doc, field)
352352
353 # date published353 # date published
354 date_published = self._set_doc_from_key(doc,354 date_published_str = self._set_doc_from_key(
355 AppInfoFields.DATE_PUBLISHED)355 doc, AppInfoFields.DATE_PUBLISHED)
356 # we use the date published value for the cataloged time as well356 # we use the date published value for the cataloged time as well
357 if date_published is not None and "catalogedtime" in axi_values:357 if date_published_str is not None:
358 LOG.debug("pkgname: %s, date_published cataloged time is: %s",358 LOG.debug("pkgname: %s, date_published cataloged time is: %s",
359 pkgname, date_published)359 pkgname, date_published_str)
360 date_published = time.mktime(time.strptime(date_published,360 date_published = time.mktime(time.strptime(date_published_str,
361 "%Y-%m-%d %H:%M:%S"))361 "%Y-%m-%d %H:%M:%S"))
362 doc.add_value(axi_values["catalogedtime"],362 # a value for our own DB
363 doc.add_value(XapianValues.DB_CATALOGED_TIME,
363 xapian.sortable_serialise(date_published))364 xapian.sortable_serialise(date_published))
365 if "catalogedtime" in axi_values:
366 # compat with a-x-i
367 doc.add_value(axi_values["catalogedtime"],
368 xapian.sortable_serialise(date_published))
364369
365 # icon (for third party)370 # icon (for third party)
366 url = self._set_doc_from_key(doc, AppInfoFields.ICON_URL)371 url = self._set_doc_from_key(doc, AppInfoFields.ICON_URL)
367372
=== modified file 'softwarecenter/enums.py'
--- softwarecenter/enums.py 2012-09-17 23:50:24 +0000
+++ softwarecenter/enums.py 2012-09-27 13:18:21 +0000
@@ -167,6 +167,9 @@
167 SC_SUPPORTED_DISTROS = 199167 SC_SUPPORTED_DISTROS = 199
168 WEBSITE = 200168 WEBSITE = 200
169 CURRENCY = 201169 CURRENCY = 201
170 # this is used to provide a cataloged time if there is no a-x-i in use
171 # or if a-x-i is not available yet
172 DB_CATALOGED_TIME = 202
170173
171174
172class AppInfoFields:175class AppInfoFields:
173176
=== modified file 'tests/gtk3/test_catview.py'
--- tests/gtk3/test_catview.py 2012-09-24 08:22:54 +0000
+++ tests/gtk3/test_catview.py 2012-09-27 13:18:21 +0000
@@ -1,6 +1,5 @@
1import unittest1import unittest
22
3from gi.repository import Gtk
4from mock import patch, Mock3from mock import patch, Mock
54
6from tests.utils import (5from tests.utils import (
@@ -76,35 +75,24 @@
76 self.assertEqual(self._cat.name, 'What\xe2\x80\x99s New')75 self.assertEqual(self._cat.name, 'What\xe2\x80\x99s New')
77 self.assertEqual(self._cat.sortmode, SortMethods.BY_CATALOGED_TIME)76 self.assertEqual(self._cat.sortmode, SortMethods.BY_CATALOGED_TIME)
7877
79 def test_new_no_sort_info_yet(self):78 def test_no_axi_cataloged_time_info_yet(self):
80 # ensure that we don't show a empty "whats new" category79 """ ensure that we show "whats new" DB_CATALOGED_TIME data if there
81 # see LP: #86598580 is no x-a-i yet """
82 db = get_test_db()81 db = get_test_db()
83 cache = db._aptcache82 cache = db._aptcache
84 # simulate a fresh install with no catalogedtime info
85 del db._axi_values["catalogedtime"]
86
87 icons = get_test_gtk3_icon_cache()83 icons = get_test_gtk3_icon_cache()
88
89 apps_filter = AppFilter(db, cache)84 apps_filter = AppFilter(db, cache)
9085
86 # simulate a fresh install with no catalogedtime info in a-x-i
87 if "catalogedtime" in db._axi_values:
88 del db._axi_values["catalogedtime"]
89
90 # create it
91 view = lobbyview.LobbyView(cache, db, icons,91 view = lobbyview.LobbyView(cache, db, icons,
92 softwarecenter.distro.get_distro(), apps_filter)92 softwarecenter.distro.get_distro(), apps_filter)
93 view.show()93 view.show_all()
9494 # and ensure its visible
95 # gui95 self.assertTrue(view.whats_new_frame.get_property("visible"))
96 win = Gtk.Window()
97 self.addCleanup(win.destroy)
98 win.set_size_request(800, 400)
99
100 scroll = Gtk.ScrolledWindow()
101 scroll.add(view)
102 scroll.show()
103 win.add(scroll)
104 win.show()
105 # test visibility
106 do_events()
107 self.assertFalse(view.whats_new_frame.get_property("visible"))
10896
10997
110class RecommendationsTestCase(CatViewBaseTestCase):98class RecommendationsTestCase(CatViewBaseTestCase):

Subscribers

People subscribed via source and target branches