have listPackages() method to support queryOpts option and convert the packages page to use paginateMethod()
This commit is contained in:
parent
fe8c5964ca
commit
2d5c661a19
3 changed files with 8 additions and 15 deletions
10
cli/koji
10
cli/koji
|
|
@ -3226,10 +3226,7 @@ def anon_handle_list_pkgs(options, session, args):
|
|||
opts['event'] = event['id']
|
||||
event['timestr'] = time.asctime(time.localtime(event['ts']))
|
||||
print "Querying at event %(id)i (%(timestr)s)" % event
|
||||
if 'tagID' in opts or 'pkgID' in opts or 'userID' in opts:
|
||||
data = session.listPackages(**opts)
|
||||
else:
|
||||
data = session.listPackagesSimple(**opts)
|
||||
data = session.listPackages(**opts)
|
||||
if not data:
|
||||
print "(no matching packages)"
|
||||
return 1
|
||||
|
|
@ -6269,10 +6266,7 @@ def handle_set_pkg_owner_global(options, session, args):
|
|||
continue
|
||||
to_change.extend(entries)
|
||||
if not packages and options.old_user:
|
||||
if 'tagID' in opts or 'pkgID' in opts or 'userID' in opts:
|
||||
entries = session.listPackages(**opts)
|
||||
else:
|
||||
entries = session.listPackagesSimple(**opts)
|
||||
entries = session.listPackages(**opts)
|
||||
if not entries:
|
||||
print "No data for user %s" % old_user['name']
|
||||
return 1
|
||||
|
|
|
|||
|
|
@ -9811,7 +9811,7 @@ class RootExports(object):
|
|||
|
||||
getPackage = staticmethod(lookup_package)
|
||||
|
||||
def listPackages(self, tagID=None, userID=None, pkgID=None, prefix=None, inherited=False, with_dups=False, event=None):
|
||||
def listPackages(self, tagID=None, userID=None, pkgID=None, prefix=None, inherited=False, with_dups=False, event=None, queryOpts=None):
|
||||
"""List if tagID and/or userID is specified, limit the
|
||||
list to packages belonging to the given user or with the
|
||||
given tag.
|
||||
|
|
@ -9833,8 +9833,7 @@ class RootExports(object):
|
|||
- blocked
|
||||
"""
|
||||
if tagID is None and userID is None and pkgID is None:
|
||||
query = """SELECT id, name from package"""
|
||||
results = _multiRow(query, {}, ('package_id', 'package_name'))
|
||||
return self.listPackagesSimple(prefix, queryOpts)
|
||||
else:
|
||||
if tagID is not None:
|
||||
tagID = get_tag_id(tagID, strict=True)
|
||||
|
|
@ -9858,7 +9857,7 @@ class RootExports(object):
|
|||
prefix = prefix.lower()
|
||||
results = [package for package in results if package['package_name'].lower().startswith(prefix)]
|
||||
|
||||
return results
|
||||
return _applyQueryOpts(results, queryOpts)
|
||||
|
||||
|
||||
def listPackagesSimple(self, prefix=None, queryOpts=None):
|
||||
|
|
|
|||
|
|
@ -833,9 +833,9 @@ def packages(environ, tagID=None, userID=None, order='package_name', start=None,
|
|||
inherited = int(inherited)
|
||||
values['inherited'] = inherited
|
||||
|
||||
kojiweb.util.paginateResults(server, values, 'listPackages',
|
||||
kw={'tagID': tagID, 'userID': userID, 'prefix': prefix, 'inherited': bool(inherited)},
|
||||
start=start, dataName='packages', prefix='package', order=order)
|
||||
packages = kojiweb.util.paginateMethod(server, values, 'listPackages',
|
||||
kw={'tagID': tagID, 'userID': userID, 'prefix': prefix, 'inherited': bool(inherited)},
|
||||
start=start, dataName='packages', prefix='package', order=order)
|
||||
|
||||
values['chars'] = _PREFIX_CHARS
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue