From ff6b5730351f9d69240f57b62103e669abc33c73 Mon Sep 17 00:00:00 2001 From: Jana Cupova Date: Dec 15 2021 08:21:30 +0000 Subject: Taginfo page shows packages with/without blocked Fixes: https://pagure.io/koji/issue/1350 --- diff --git a/cli/koji_cli/commands.py b/cli/koji_cli/commands.py index 810238c..6135aaf 100644 --- a/cli/koji_cli/commands.py +++ b/cli/koji_cli/commands.py @@ -3227,8 +3227,15 @@ def anon_handle_list_pkgs(goptions, session, args): if options.show_blocked: parser.error("--show-blocked makes sense only with --tag," " --owner or --package") + if options.show_blocked: + opts['with_blocked'] = options.show_blocked + + try: + data = session.listPackages(**opts) + except koji.ParameterError: + del opts['with_blocked'] + data = session.listPackages(**opts) - data = session.listPackages(**opts) if not data: error("(no matching packages)") if not options.quiet: diff --git a/hub/kojihub.py b/hub/kojihub.py index f882520..971f999 100644 --- a/hub/kojihub.py +++ b/hub/kojihub.py @@ -1121,7 +1121,7 @@ def pkglist_setarches(taginfo, pkginfo, arches, force=False): def readPackageList(tagID=None, userID=None, pkgID=None, event=None, inherit=False, - with_dups=False, with_owners=True): + with_dups=False, with_owners=True, with_blocked=True): """Returns the package list for the specified tag or user. One of (tagID,userID,pkgID) must be specified @@ -1175,6 +1175,8 @@ def readPackageList(tagID=None, userID=None, pkgID=None, event=None, inherit=Fal 'users ON users.id = tag_package_owners.owner' ] clauses.append(eventCondition(event, table='tag_package_owners')) + if not with_blocked: + clauses.append('NOT tag_packages.blocked') fields, aliases = zip(*fields) query = QueryProcessor(columns=fields, aliases=aliases, tables=tables, joins=joins, clauses=clauses, values=locals()) @@ -12295,7 +12297,8 @@ 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, queryOpts=None, with_owners=True): + with_dups=False, event=None, queryOpts=None, with_owners=True, + with_blocked=False): """ Returns a list of packages in Koji. @@ -12340,7 +12343,8 @@ class RootExports(object): pkgID = get_package_id(pkgID, strict=True) result_list = list(readPackageList(tagID=tagID, userID=userID, pkgID=pkgID, inherit=inherited, with_dups=with_dups, - event=event, with_owners=with_owners).values()) + event=event, with_owners=with_owners, + with_blocked=with_blocked).values()) if with_dups: # when with_dups=True, readPackageList returns a list of list of dicts # convert it to a list of dicts for consistency diff --git a/www/kojiweb/index.py b/www/kojiweb/index.py index b5e0122..8525c8f 100644 --- a/www/kojiweb/index.py +++ b/www/kojiweb/index.py @@ -984,8 +984,11 @@ def taginfo(environ, tagID, all='0', packageOrder='package_name', packageStart=N all = int(all) numPackages = server.count('listPackages', tagID=tag['id'], inherited=True, with_owners=False) + numPackagesBlocked = server.count('listPackages', tagID=tag['id'], inherited=True, + with_owners=False, with_blocked=True) numBuilds = server.count('listTagged', tag=tag['id'], inherit=True) values['numPackages'] = numPackages + values['numPackagesBlocked'] = numPackagesBlocked values['numBuilds'] = numBuilds inheritance = server.getFullInheritance(tag['id']) diff --git a/www/kojiweb/taginfo.chtml b/www/kojiweb/taginfo.chtml index 3acb8ea..a644cb9 100644 --- a/www/kojiweb/taginfo.chtml +++ b/www/kojiweb/taginfo.chtml @@ -124,6 +124,10 @@ $numPackages + Packages (blocked packages included) + $numPackagesBlocked + + Builds $numBuilds