Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

- don't show newest only when installed filter is active

- cache the search result in backend to improve speed when changing filter under search
- delete debug code
  • Loading branch information...
commit b61c98fc77f89669635cf10be4c7b1f6f5c5d389 1 parent 17a19bd
Tim Lauridsen authored
Showing with 29 additions and 23 deletions.
  1. +22 −18 src/yumexbackend/yum_server.py
  2. +7 −5 src/yumexgui/__init__.py
View
40 src/yumexbackend/yum_server.py
@@ -202,6 +202,8 @@ def __init__(self, debuglevel=2, plugins=True, offline=False, enabled_repos=None
self._updateMetadata = None # Update metadata cache
self._updates_list = None
self._obsoletes_list = None
+ self._last_search = None
+ self._last_search_result = None
self.write(':started') # Let the front end know that we are up and running
def _is_local_repo(self, repo):
@@ -1019,7 +1021,6 @@ def _get_action(self, po):
return po, action
def _return_packages(self, pkgs, filter=None):
- updates = self._get_updates()
for po in pkgs:
po, action = self._get_action(po)
if filter and action not in filter: # Check if action is in filter
@@ -1045,7 +1046,6 @@ def _limit_package_list(self, pkgs):
def search_prefix(self, prefix, show_newest_only):
prefix += '*'
- self.debug("prefix: %s " % prefix)
pkgs = self.pkgSack.returnPackages(patterns=[prefix])
ipkgs = self.rpmdb.returnPackages(patterns=[prefix])
pkgs.extend(ipkgs)
@@ -1063,22 +1063,26 @@ def search(self, args):
keys = unpack(args[0])
filters = unpack(args[1])
show_newest_only = unpack(args[2])
- ygh = self.doPackageLists(pkgnarrow='updates')
- pkgs = {}
- for found in self.searchGenerator(filters, keys, showdups=True, keys=True):
- pkg = found[0]
- fkeys = found[1]
- if not len(fkeys) == len(keys): # skip the result if not all keys matches
- continue
- na = "%s.%s" % (pkg.name, pkg.arch)
- if not na in pkgs:
- pkgs[na] = [pkg]
- else:
- pkgs[na].append(pkg)
- packages = []
- for na in pkgs:
- best = self._limit_package_list(pkgs[na])
- packages.extend(best)
+ if keys != self._last_search:
+ self._last_search = keys
+ pkgs = {}
+ for found in self.searchGenerator(filters, keys, showdups=True, keys=True):
+ pkg = found[0]
+ fkeys = found[1]
+ if not len(fkeys) == len(keys): # skip the result if not all keys matches
+ continue
+ na = "%s.%s" % (pkg.name, pkg.arch)
+ if not na in pkgs:
+ pkgs[na] = [pkg]
+ else:
+ pkgs[na].append(pkg)
+ packages = []
+ for na in pkgs:
+ best = self._limit_package_list(pkgs[na])
+ packages.extend(best)
+ self._last_search_result = packages
+ else:
+ packages = self._last_search_result
if show_newest_only:
packages = packagesNewestByName(packages)
self._return_packages(packages)
View
12 src/yumexgui/__init__.py
@@ -1317,15 +1317,18 @@ def on_packageFilter_changed(self, widget, active):
self._add_packages(pkgs, label)
self.debug('END: Getting %s packages' % active)
else: # This is a search
+ if active == "installed": # always show all installed packages
+ newest_only = False
+ else:
+ newest_only = self.settings.show_newest_only
+
self._last_search_filter = widget
if self.typeahead_active: # type-ahead
keys = self.ui.packageSearch.get_text().split(' ')
txt = keys[0]
if len(txt) >= 3:
self.ui.packageSearch.set_sensitive(False)
- self.debug("SEARCH : %s" % txt)
- pkgs = self.backend.search_prefix(txt, self.settings.show_newest_only, active)
- self.debug("SEARCH : got %i packages" % len(pkgs))
+ pkgs = self.backend.search_prefix(txt, newest_only, active)
if not self.settings.search:
self._hide_filters_on_search(hide = True)
self.packages.add_packages(pkgs)
@@ -1338,8 +1341,7 @@ def on_packageFilter_changed(self, widget, active):
else: # Normal search
filters = self.search_options.get_filters()
keys = self.ui.packageSearch.get_text().split(' ')
- print "DEBUG (active):", active
- pkgs = self.backend.search(keys, filters, self.settings.show_newest_only, active)
+ pkgs = self.backend.search(keys, filters, newest_only, active)
if not self.settings.search:
self._hide_filters_on_search(hide = True)
self.packages.add_packages(pkgs)
Please sign in to comment.
Something went wrong with that request. Please try again.