paginate the component buildroot list on the rpminfo page

This commit is contained in:
Mike Bonnet 2009-06-11 18:05:48 -04:00
parent 5b11e90fea
commit 87576b0dc1
3 changed files with 51 additions and 31 deletions

View file

@ -2948,7 +2948,7 @@ def get_channel(channelInfo, strict=False):
return _singleRow(query, locals(), fields, strict)
def query_buildroots(hostID=None, tagID=None, state=None, rpmID=None, taskID=None, buildrootID=None):
def query_buildroots(hostID=None, tagID=None, state=None, rpmID=None, taskID=None, buildrootID=None, queryOpts=None):
"""Return a list of matching buildroots
Optional args:
@ -2969,14 +2969,13 @@ def query_buildroots(hostID=None, tagID=None, state=None, rpmID=None, taskID=Non
('EXTRACT(EPOCH FROM retire_events.time)','retire_ts'),
('repo_create.id', 'repo_create_event_id'), ('repo_create.time', 'repo_create_event_time')]
query = """SELECT %s FROM buildroot
JOIN host ON host.id = buildroot.host_id
JOIN repo ON repo.id = buildroot.repo_id
JOIN tag ON tag.id = repo.tag_id
JOIN events AS create_events ON create_events.id = buildroot.create_event
LEFT OUTER JOIN events AS retire_events ON buildroot.retire_event = retire_events.id
JOIN events AS repo_create ON repo_create.id = repo.create_event
"""
tables = ['buildroot']
joins=['host ON host.id = buildroot.host_id',
'repo ON repo.id = buildroot.repo_id',
'tag ON tag.id = repo.tag_id',
'events AS create_events ON create_events.id = buildroot.create_event',
'LEFT OUTER JOIN events AS retire_events ON buildroot.retire_event = retire_events.id',
'events AS repo_create ON repo_create.id = repo.create_event']
clauses = []
if buildrootID != None:
@ -2994,20 +2993,16 @@ def query_buildroots(hostID=None, tagID=None, state=None, rpmID=None, taskID=Non
else:
clauses.append('buildroot.state = %(state)i')
if rpmID != None:
query += """JOIN buildroot_listing ON buildroot.id = buildroot_listing.buildroot_id
"""
joins.append('buildroot_listing ON buildroot.id = buildroot_listing.buildroot_id')
fields.append(('buildroot_listing.is_update', 'is_update'))
clauses.append('buildroot_listing.rpm_id = %(rpmID)i')
if taskID != None:
clauses.append('buildroot.task_id = %(taskID)i')
query = query % ', '.join([pair[0] for pair in fields])
if len(clauses) > 0:
query += 'WHERE ' + ' AND '.join(clauses)
return _multiRow(query, locals(), [pair[1] for pair in fields])
query = QueryProcessor(columns=[f[0] for f in fields], aliases=[f[1] for f in fields],
tables=tables, joins=joins, clauses=clauses, values=locals(),
opts=queryOpts)
return query.execute()
def get_buildroot(buildrootID, strict=False):
"""Return information about a buildroot. buildrootID must be an int ID."""

View file

@ -1159,7 +1159,7 @@ def userinfo(req, userID, packageOrder='package_name', packageStart=None, buildO
return _genHTML(req, 'userinfo.chtml')
def rpminfo(req, rpmID, fileOrder='name', fileStart=None):
def rpminfo(req, rpmID, fileOrder='name', fileStart=None, buildrootOrder='-id', buildrootStart=None):
values = _initValues(req, 'RPM Info', 'builds')
server = _getServer(req)
@ -1190,8 +1190,9 @@ def rpminfo(req, rpmID, fileOrder='name', fileStart=None):
headers = server.getRPMHeaders(rpm['id'], headers=['summary', 'description'])
values['summary'] = koji.fixEncoding(headers.get('summary'))
values['description'] = koji.fixEncoding(headers.get('description'))
buildroots = server.listBuildroots(rpmID=rpm['id'])
buildroots.sort(kojiweb.util.sortByKeyFunc('-create_event_time'))
buildroots = kojiweb.util.paginateMethod(server, values, 'listBuildroots', kw={'rpmID': rpm['id']},
start=buildrootStart, dataName='buildroots', prefix='buildroot',
order=buildrootOrder)
values['rpmID'] = rpmID
values['rpm'] = rpm

View file

@ -3,6 +3,8 @@
#import time
#import urllib
#attr _PASSTHROUGH = ['rpmID', 'fileOrder', 'fileStart', 'buildrootOrder', 'buildrootStart']
#include "includes/header.chtml"
#set $epoch = ($rpm.epoch != None and $str($rpm.epoch) + ':' or '')
<h4>Information for RPM <a href="rpminfo?rpmID=$rpm.id">$rpm.name-$epoch$rpm.version-$rpm.release.${rpm.arch}.rpm</a></h4>
@ -141,7 +143,7 @@
#if $len($filePages) > 1
<form class="pageJump" action="">
Page:
<select onchange="javascript: window.location = 'rpminfo?fileStart=' + this.value * $fileRange + '$util.passthrough($self, 'rpmID', 'fileOrder')#filelist';">
<select onchange="javascript: window.location = 'rpminfo?fileStart=' + this.value * $fileRange + '$util.passthrough_except($self, 'fileStart')#filelist';">
#for $pageNum in $filePages
<option value="$pageNum"#if $pageNum == $fileCurrentPage then ' selected="selected"' else ''#>#echo $pageNum + 1#</option>
#end for
@ -149,17 +151,17 @@
</form>
#end if
#if $fileStart > 0
<a href="rpminfo?fileStart=#echo $fileStart - $fileRange #$util.passthrough($self, 'rpmID', 'fileOrder')#filelist">&lt;&lt;&lt;</a>
<a href="rpminfo?fileStart=#echo $fileStart - $fileRange #$util.passthrough_except($self, 'fileStart')#filelist">&lt;&lt;&lt;</a>
#end if
<strong>#echo $fileStart + 1 # through #echo $fileStart + $fileCount # of $totalFiles</strong>
#if $fileStart + $fileCount < $totalFiles
<a href="rpminfo?fileStart=#echo $fileStart + $fileRange#$util.passthrough($self, 'rpmID', 'fileOrder')#filelist">&gt;&gt;&gt;</a>
<a href="rpminfo?fileStart=#echo $fileStart + $fileRange#$util.passthrough_except($self, 'fileStart')#filelist">&gt;&gt;&gt;</a>
#end if
</td>
</tr>
<tr class="list-header">
<th><a href="rpminfo?fileOrder=$util.toggleOrder($self, 'name', 'fileOrder')$util.passthrough($self, 'rpmID')#filelist">Name</a> $util.sortImage($self, 'name', 'fileOrder')</th>
<th><a href="rpminfo?fileOrder=$util.toggleOrder($self, 'size', 'fileOrder')$util.passthrough($self, 'rpmID')#filelist">Size</a> $util.sortImage($self, 'size', 'fileOrder')</th>
<th><a href="rpminfo?fileOrder=$util.toggleOrder($self, 'name', 'fileOrder')$util.passthrough_except($self, 'fileOrder', 'fileStart')#filelist">Name</a> $util.sortImage($self, 'name', 'fileOrder')</th>
<th><a href="rpminfo?fileOrder=$util.toggleOrder($self, 'size', 'fileOrder')$util.passthrough_except($self, 'fileOrder', 'fileStart')#filelist">Size</a> $util.sortImage($self, 'size', 'fileOrder')</th>
</tr>
#for $file in $files
<tr class="$util.rowToggle($self)">
@ -174,26 +176,48 @@
</tr>
#end if
<tr>
<th>Component&nbsp;of</th>
<th id="buildrootlist">Component&nbsp;of</th>
<td class="container">
#if $len($buildroots) > 0
<table class="nested data-list">
<tr>
<td class="paginate" colspan="3">
#if $len($buildrootPages) > 1
<form class="pageJump" action="">
Page:
<select onchange="javascript: window.location = 'rpminfo?buildrootStart=' + this.value * $buildrootRange + '$util.passthrough_except($self, 'buildrootStart')#buildrootlist';">
#for $pageNum in $buildrootPages
<option value="$pageNum"#if $pageNum == $buildrootCurrentPage then ' selected="selected"' else ''#>#echo $pageNum + 1#</option>
#end for
</select>
</form>
#end if
#if $buildrootStart > 0
<a href="rpminfo?buildrootStart=#echo $buildrootStart - $buildrootRange #$util.passthrough_except($self, 'buildrootStart')#buildrootlist">&lt;&lt;&lt;</a>
#end if
<strong>#echo $buildrootStart + 1 # through #echo $buildrootStart + $buildrootCount # of $totalBuildroots</strong>
#if $buildrootStart + $buildrootCount < $totalBuildroots
<a href="rpminfo?buildrootStart=#echo $buildrootStart + $buildrootRange#$util.passthrough_except($self, 'buildrootStart')#buildrootlist">&gt;&gt;&gt;</a>
#end if
</td>
</tr>
<tr class="list-header">
<th>Buildroot</th><th>State</th><th>Update?</th>
<th><a href="rpminfo?buildrootOrder=$util.toggleOrder($self, 'id', 'buildrootOrder')$util.passthrough_except($self, 'buildrootOrder', 'buildrootStart')#buildrootlist">Buildroot</a> $util.sortImage($self, 'id', 'buildrootOrder')</th>
<th><a href="rpminfo?buildrootOrder=$util.toggleOrder($self, 'create_event_time', 'buildrootOrder')$util.passthrough_except($self, 'buildrootOrder', 'buildrootStart')#buildrootlist">Created</a> $util.sortImage($self, 'create_event_time', 'buildrootOrder')</th>
<th><a href="rpminfo?buildrootOrder=$util.toggleOrder($self, 'state', 'buildrootOrder')$util.passthrough_except($self, 'buildrootOrder', 'buildrootStart')#buildrootlist">State</a> $util.sortImage($self, 'state', 'buildrootOrder')</th>
</tr>
#for $buildroot in $buildroots
<tr class="$util.rowToggle($self)">
<td><a href="buildrootinfo?buildrootID=$buildroot.id">$buildroot.tag_name-$buildroot.id-$buildroot.repo_id</a></td>
<td>$util.formatTime($buildroot.create_event_time)</td>
<td>$util.imageTag($util.brStateName($buildroot.state))</td>
#set $update = $buildroot.is_update and 'yes' or 'no'
<td class="$update">$util.imageTag($update)</td>
</tr>
#end for
</table>
#else
No Buildroots
#end if
</td>
</td>
</tr>
</table>