allow filtering tasks by channel in webui, show active task count on channelinfo page

This commit is contained in:
Mike McLean 2010-07-22 16:01:45 -04:00
parent 054e5cb5fb
commit 7bac64b85d
4 changed files with 26 additions and 4 deletions

View file

@ -7571,6 +7571,7 @@ class RootExports(object):
state[list]: limit to tasks of given state
owner[int]: limit to tasks owned by the user with the given ID
host_id[int]: limit to tasks running on the host with the given ID
channel_id[int]: limit to tasks in the specified channel
parent[int]: limit to tasks with the given parent
decode[bool]: whether or not xmlrpc data in the 'request' and 'result'
fields should be decoded; defaults to False
@ -7612,7 +7613,7 @@ class RootExports(object):
for f in ['arch','state']:
if opts.has_key(f):
conditions.append('%s IN %%(%s)s' % (f, f))
for f in ['owner', 'host_id', 'parent']:
for f in ['owner', 'host_id', 'channel_id', 'parent']:
if opts.has_key(f):
if opts[f] is None:
conditions.append('%s IS NULL' % f)

View file

@ -11,6 +11,9 @@
<tr>
<th>ID</th><td>$channel.id</td>
</tr>
<tr>
<th>Active Tasks</th><td><a href="tasks?view=flat&channelID=$channel.id">$taskCount</a></td>
</tr>
<tr>
<th>Hosts</th>
<td>

View file

@ -372,7 +372,7 @@ _TOPLEVEL_TASKS = ['build', 'buildNotification', 'chainbuild', 'maven', 'newRepo
# Tasks that can have children
_PARENT_TASKS = ['build', 'chainbuild', 'maven', 'newRepo']
def tasks(req, owner=None, state='active', view='tree', method='all', hostID=None, start=None, order='-id'):
def tasks(req, owner=None, state='active', view='tree', method='all', hostID=None, channelID=None, start=None, order='-id'):
values = _initValues(req, 'Tasks', 'tasks')
server = _getServer(req)
@ -444,6 +444,19 @@ def tasks(req, owner=None, state='active', view='tree', method='all', hostID=Non
values['host'] = None
values['hostID'] = None
if channelID:
try:
channelID = int(channelID)
except ValueError:
pass
channel = server.getChannel(channelID, strict=True)
opts['channel_id'] = channel['id']
values['channel'] = channel
values['channelID'] = channel['id']
else:
values['channel'] = None
values['channelID'] = None
loggedInUser = req.currentUser
values['loggedInUser'] = loggedInUser
@ -1506,6 +1519,11 @@ def channelinfo(req, channelID):
values['title'] = channel['name'] + ' | Channel Info'
states = [koji.TASK_STATES[s] for s in ('FREE', 'OPEN', 'ASSIGNED')]
values['taskCount'] = \
server.listTasks(opts={'channel_id': channelID, 'state': states},
queryOpts={'countOnly': True})
hosts = server.listHosts(channelID=channelID)
hosts.sort(_sortbyname)

View file

@ -36,11 +36,11 @@ All
#end if
#end def
#attr _PASSTHROUGH = ['owner', 'state', 'view', 'method', 'hostID', 'order']
#attr _PASSTHROUGH = ['owner', 'state', 'view', 'method', 'hostID', 'channelID', 'order']
#include "includes/header.chtml"
<h4>$headerPrefix($state) #if $view == 'toplevel' then 'toplevel' else ''# #if $method != 'all' then $method else ''# Tasks#if $ownerObj then ' owned by <a href="userinfo?userID=%i">%s</a>' % ($ownerObj.id, $ownerObj.name) else ''##if $host then ' on host <a href="hostinfo?hostID=%i">%s</a>' % ($host.id, $host.name) else ''#</h4>
<h4>$headerPrefix($state) #if $view == 'toplevel' then 'toplevel' else ''# #if $method != 'all' then $method else ''# Tasks#if $ownerObj then ' owned by <a href="userinfo?userID=%i">%s</a>' % ($ownerObj.id, $ownerObj.name) else ''##if $host then ' on host <a href="hostinfo?hostID=%i">%s</a>' % ($host.id, $host.name) else ''# #if $channel then ' in channel <a href="channelinfo?channelID=%i">%s</a>' % ($channel.id, $channel.name) else ''#</h4>
<table class="data-list">
<tr>