From c3a4f088b77ac9cd6d351daf99ca7de23f8f7796 Mon Sep 17 00:00:00 2001 From: Mike McLean Date: Jan 06 2021 21:43:18 +0000 Subject: [PATCH 1/2] history query by key Fixes: https://pagure.io/koji/issue/2590 --- diff --git a/cli/koji_cli/commands.py b/cli/koji_cli/commands.py index 3a819e1..6a1ec94 100644 --- a/cli/koji_cli/commands.py +++ b/cli/koji_cli/commands.py @@ -4476,6 +4476,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("--key", help=_("Only show entries related to given key")) parser.add_option("--before", type="time", help=_("Only show entries before this time, ") + TimeOption.get_help()) parser.add_option("--after", type="time", @@ -4502,7 +4503,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', 'key'): val = getattr(options, opt) if val: kwargs[opt] = val diff --git a/hub/kojihub.py b/hub/kojihub.py index f13d071..8d4f829 100644 --- a/hub/kojihub.py +++ b/hub/kojihub.py @@ -7847,6 +7847,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 == 'key': + 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()) From ba1dd8bd217d837ab7e9be5481b5e5c259fdd5d9 Mon Sep 17 00:00:00 2001 From: Mike McLean Date: Jan 06 2021 21:44:09 +0000 Subject: [PATCH 2/2] rename arg --- diff --git a/cli/koji_cli/commands.py b/cli/koji_cli/commands.py index 6a1ec94..a8a808c 100644 --- a/cli/koji_cli/commands.py +++ b/cli/koji_cli/commands.py @@ -4476,7 +4476,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("--key", help=_("Only show entries related to given key")) + 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", @@ -4503,7 +4503,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', 'key'): + 'after', 'host', 'channel', 'xkey'): val = getattr(options, opt) if val: kwargs[opt] = val diff --git a/hub/kojihub.py b/hub/kojihub.py index 8d4f829..ed3716b 100644 --- a/hub/kojihub.py +++ b/hub/kojihub.py @@ -7847,7 +7847,7 @@ 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 == 'key': + elif arg == 'xkey': if 'key' not in table_fields[table]: skip = True break