#610 show components for all archives
Merged 4 years ago by mikem. Opened 4 years ago by tkopecek.
tkopecek/koji issue545  into  master

@@ -148,9 +148,14 @@ 

          #end if

        </td>

      </tr>

-     #if 'rootid' in $archive and $archive.rootid

+     #if $show_rpm_components

      <tr>

-       <th colspan="2"><a href="rpmlist?imageID=$archive.id&amp;type=image" title="RPMs that where installed to the image">Installed RPMs</a></th>

+       <th colspan="2"><a href="rpmlist?imageID=$archive.id&amp;type=image" title="RPM components that are part of this archive">RPM components</a></th>

+     </tr>

+     #end if

+     #if $show_archive_components

+     <tr>

+       <th colspan="2"><a href="archivelist?imageID=$archive.id&amp;type=image" title="Archive components that are part of this archive">Archive components</a></th>

      </tr>

      #end if

    </table>

file modified
+19 -9
@@ -1,9 +1,19 @@ 

  #from kojiweb import util

  

  #include "includes/header.chtml"

+ #

+ #def getID()

+   #if $type == 'image'

+ imageID=$image.id #slurp

+   #else

+ buildrootID=$buildroot.id #slurp

+   #end if

+ #end def

  

    #if $type == 'component'

    <h4>Component Archives of buildroot <a href="buildrootinfo?buildrootID=$buildroot.id">$util.brLabel($buildroot)</a></h4>

+   #elif $type == 'image'

+   <h4>Archives installed in <a href="archiveinfo?archiveID=$image.id">$image.filename</a></h4>

    #else

    <h4>Archives built in buildroot <a href="buildrootinfo?buildrootID=$buildroot.id">$util.brLabel($buildroot)</a></h4>

    #end if
@@ -14,7 +24,7 @@ 

          #if $len($archivePages) > 1

          <form class="pageJump">

            Page:

-           <select onchange="javascript: window.location = 'archivelist?buildrootID=$buildroot.id&start=' + this.value * $archiveRange + '$util.passthrough($self, 'order', 'type')';">

+           <select onchange="javascript: window.location = 'archivelist?$getID()&start=' + this.value * $archiveRange + '$util.passthrough($self, 'order', 'type')';">

              #for $pageNum in $archivePages

              <option value="$pageNum"#if $pageNum == $archiveCurrentPage then ' selected' else ''#>#echo $pageNum + 1#</option>

              #end for
@@ -22,21 +32,21 @@ 

          </form>

          #end if

          #if $archiveStart > 0

-         <a href="archivelist?buildrootID=$buildroot.id&start=#echo $archiveStart - $archiveRange #$util.passthrough($self, 'order', 'type')">&lt;&lt;&lt;</a>

+         <a href="archivelist?$getID()&start=#echo $archiveStart - $archiveRange #$util.passthrough($self, 'order', 'type')">&lt;&lt;&lt;</a>

          #end if

          #if $totalArchives != 0

          <strong>Archives #echo $archiveStart + 1 # through #echo $archiveStart + $archiveCount # of $totalArchives</strong>

          #end if

          #if $archiveStart + $archiveCount < $totalArchives

-         <a href="archivelist?buildrootID=$buildroot.id&start=#echo $archiveStart + $archiveRange#$util.passthrough($self, 'order', 'type')">&gt;&gt;&gt;</a>

+         <a href="archivelist?$getID()&start=#echo $archiveStart + $archiveRange#$util.passthrough($self, 'order', 'type')">&gt;&gt;&gt;</a>

          #end if

        </td>

      </tr>

      <tr class="list-header">

-       <th><a href="archivelist?buildrootID=$buildroot.id&order=$util.toggleOrder($self, 'filename')$util.passthrough($self, 'type')">Filename</a> $util.sortImage($self, 'filename')</th>

-       <th><a href="archivelist?buildrootID=$buildroot.id&order=$util.toggleOrder($self, 'type_name')$util.passthrough($self, 'type')">Type</a> $util.sortImage($self, 'type_name')</th>

+       <th><a href="archivelist?$getID()&order=$util.toggleOrder($self, 'filename')$util.passthrough($self, 'type')">Filename</a> $util.sortImage($self, 'filename')</th>

+       <th><a href="archivelist?$getID()&order=$util.toggleOrder($self, 'type_name')$util.passthrough($self, 'type')">Type</a> $util.sortImage($self, 'type_name')</th>

        #if $type == 'component'

-       <th><a href="archivelist?buildrootID=$buildroot.id&order=$util.toggleOrder($self, 'project')$util.passthrough($self, 'type')">Build Dependency?</a> $util.sortImage($self, 'project')</th>

+       <th><a href="archivelist?$getID()&order=$util.toggleOrder($self, 'project')$util.passthrough($self, 'type')">Build Dependency?</a> $util.sortImage($self, 'project')</th>

        #end if

      </tr>

      #if $len($archives) > 0
@@ -60,7 +70,7 @@ 

          #if $len($archivePages) > 1

          <form class="pageJump">

            Page:

-           <select onchange="javascript: window.location = 'archivelist?buildrootID=$buildroot.id&start=' + this.value * $archiveRange + '$util.passthrough($self, 'order', 'type')';">

+           <select onchange="javascript: window.location = 'archivelist?$getID()&start=' + this.value * $archiveRange + '$util.passthrough($self, 'order', 'type')';">

              #for $pageNum in $archivePages

              <option value="$pageNum"#if $pageNum == $archiveCurrentPage then ' selected' else ''#>#echo $pageNum + 1#</option>

              #end for
@@ -68,13 +78,13 @@ 

          </form>

          #end if

          #if $archiveStart > 0

-         <a href="archivelist?buildrootID=$buildroot.id&start=#echo $archiveStart - $archiveRange #$util.passthrough($self, 'order', 'type')">&lt;&lt;&lt;</a>

+         <a href="archivelist?$getID()&start=#echo $archiveStart - $archiveRange #$util.passthrough($self, 'order', 'type')">&lt;&lt;&lt;</a>

          #end if

          #if $totalArchives != 0

          <strong>Archives #echo $archiveStart + 1 # through #echo $archiveStart + $archiveCount # of $totalArchives</strong>

          #end if

          #if $archiveStart + $archiveCount < $totalArchives

-         <a href="archivelist?buildrootID=$buildroot.id&start=#echo $archiveStart + $archiveRange#$util.passthrough($self, 'order', 'type')">&gt;&gt;&gt;</a>

+         <a href="archivelist?$getID()&start=#echo $archiveStart + $archiveRange#$util.passthrough($self, 'order', 'type')">&gt;&gt;&gt;</a>

          #end if

        </td>

      </tr>

file modified
+28 -13
@@ -1432,6 +1432,8 @@ 

      values['wininfo'] = wininfo

      values['builtInRoot'] = builtInRoot

      values['buildroots'] = buildroots

+     values['show_rpm_components'] = server.listRPMs(imageID=archive['id'], queryOpts={'limit':1})

+     values['show_archive_components'] = server.listArchives(imageID=archive['id'], queryOpts={'limit':1})

  

      return _genHTML(environ, 'archiveinfo.chtml')

  
@@ -1721,27 +1723,40 @@ 

  

      return _genHTML(environ, 'rpmlist.chtml')

  

- def archivelist(environ, buildrootID, type, start=None, order='filename'):

+ def archivelist(environ, type, buildrootID=None, imageID=None, start=None, order='filename'):

      values = _initValues(environ, 'Archive List', 'hosts')

      server = _getServer(environ)

  

-     buildrootID = int(buildrootID)

-     buildroot = server.getBuildroot(buildrootID)

-     if buildroot == None:

-         raise koji.GenericError('unknown buildroot ID: %i' % buildrootID)

+     if buildrootID is not None:

+         buildrootID = int(buildrootID)

+         buildroot = server.getBuildroot(buildrootID)

+         values['buildroot'] = buildroot

  

-     if type == 'component':

-         kojiweb.util.paginateMethod(server, values, 'listArchives', kw={'componentBuildrootID': buildroot['id']},

-                                     start=start, dataName='archives', prefix='archive', order=order)

-     elif type == 'built':

-         kojiweb.util.paginateMethod(server, values, 'listArchives', kw={'buildrootID': buildroot['id']},

+         if buildroot == None:

+             raise koji.GenericError('unknown buildroot ID: %i' % buildrootID)

+ 

+         if type == 'component':

+             kojiweb.util.paginateMethod(server, values, 'listArchives', kw={'componentBuildrootID': buildroot['id']},

+                                         start=start, dataName='archives', prefix='archive', order=order)

+         elif type == 'built':

+             kojiweb.util.paginateMethod(server, values, 'listArchives', kw={'buildrootID': buildroot['id']},

                                      start=start, dataName='archives', prefix='archive', order=order)

+         else:

+             raise koji.GenericError('unrecognized type of archivelist')

+     elif imageID is not None:

+         imageID = int(imageID)

+         values['image'] = server.getArchive(imageID)

+         # If/When future image types are supported, add elifs here if needed.

+         if type == 'image':

+             kojiweb.util.paginateMethod(server, values, 'listArchives', kw={'imageID': imageID},

+                                         start=start, dataName='archives', prefix='archive', order=order)

+         else:

+             raise koji.GenericError('unrecognized type of archivelist')

      else:

-         raise koji.GenericError('invalid type: %s' % type)

+         # It is an error if neither buildrootID and imageID are defined.

+         raise koji.GenericError('Both buildrootID and imageID are None')

  

-     values['buildroot'] = buildroot

      values['type'] = type

- 

      values['order'] = order

  

      return _genHTML(environ, 'archivelist.chtml')

Even with the query limit, using a server.listRPMs() call as a boolean flag raises a red flag. Maybe ok, can can we check how much time this takes on some live servers?
Also, archives can have other archives (not just rpms) as components now.

It is not that slow - hard to decide what is sustainable limit here (do we've have some statistic of this page displays from some production env?)

Other option would be to display link everytime even if it is leading to empty list, so calls are executed only on component list page.

rebased onto a93c422f1a44e3431d92658cae9fc2ce1c6278aa

4 years ago

rebased onto d0fc12c

4 years ago

Commit bc02f03 fixes this pull-request

Pull-Request has been merged by mikem

4 years ago