From 26ea01a7dc375a185d2de270d1e4cce769b6e5e5 Mon Sep 17 00:00:00 2001 From: Tomas Kopecek Date: Jan 26 2021 13:09:53 +0000 Subject: PR#2589: history query by key Merges #2589 https://pagure.io/koji/pull-request/2589 Fixes #2590 https://pagure.io/koji/issue/2590 --- diff --git a/cli/koji_cli/commands.py b/cli/koji_cli/commands.py index 432d182..1eec550 100644 --- a/cli/koji_cli/commands.py +++ b/cli/koji_cli/commands.py @@ -4475,6 +4475,7 @@ def anon_handle_list_history(goptions, session, args): parser.add_option("--group", help=_("Only show entries relating to a given group")) parser.add_option("--host", help=_("Only show entries related to given host")) parser.add_option("--channel", help=_("Only show entries related to given channel")) + parser.add_option("--xkey", help=_("Only show entries related to given tag extra key")) parser.add_option("--before", type="time", help=_("Only show entries before this time, ") + TimeOption.get_help()) parser.add_option("--after", type="time", @@ -4501,7 +4502,7 @@ def anon_handle_list_history(goptions, session, args): limited = False for opt in ('package', 'tag', 'build', 'editor', 'user', 'permission', 'cg', 'external_repo', 'build_target', 'group', 'before', - 'after', 'host', 'channel'): + 'after', 'host', 'channel', 'xkey'): val = getattr(options, opt) if val: kwargs[opt] = val diff --git a/hub/kojihub.py b/hub/kojihub.py index d98e173..7333164 100644 --- a/hub/kojihub.py +++ b/hub/kojihub.py @@ -7852,6 +7852,12 @@ def query_history(tables=None, **kwargs): clauses.append(' OR '.join([c_test, r_test])) fields[c_test] = '_created_before_event' fields[r_test] = '_revoked_before_event' + elif arg == 'xkey': + if 'key' not in table_fields[table]: + skip = True + break + data['key'] = str(value) + clauses.append("%s.key = %%(key)s" % table) if skip: continue fields, aliases = zip(*fields.items())