support querying history by host and channel

This commit is contained in:
Mike McLean 2018-04-27 15:01:42 -04:00
parent 5ec9e2379c
commit 88b3876b2a
2 changed files with 15 additions and 1 deletions

View file

@ -4180,6 +4180,8 @@ def anon_handle_list_history(goptions, session, args):
parser.add_option("--external-repo", "--erepo", help=_("Only show entries relating to a given external repo"))
parser.add_option("--build-target", "--target", help=_("Only show entries relating to a given build target"))
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("--before", metavar="TIMESTAMP", help=_("Only show entries before timestamp"))
parser.add_option("--after", metavar="TIMESTAMP", help=_("Only show entries after timestamp"))
parser.add_option("--before-event", metavar="EVENT_ID", type='int', help=_("Only show entries before event"))
@ -4217,7 +4219,7 @@ def anon_handle_list_history(goptions, session, args):
parser.error(_("Invalid time specification: %s") % val)
for opt in ('package', 'tag', 'build', 'editor', 'user', 'permission',
'cg', 'external_repo', 'build_target', 'group', 'before',
'after'):
'after', 'host', 'channel'):
val = getattr(options, opt)
if val:
kwargs[opt] = val

View file

@ -6719,6 +6719,18 @@ def query_history(tables=None, **kwargs):
break
data['build_id'] = get_build(value, strict=True)['id']
clauses.append("build.id = %(build_id)i")
elif arg == 'host':
if 'host' not in joined:
skip = True
break
data['host_id'] = get_id('host', value, strict=False)
clauses.append("host.id = %(host_id)i")
elif arg == 'channel':
if 'channels' not in joined:
skip = True
break
data['channel_id'] = get_id('channels', value, strict=False)
clauses.append("channels.id = %(channel_id)i")
elif arg == 'package':
pkg_field_name = "%s.package" % table
if 'package' in joined: