#3009 listBuilds/list-builds filtering via CG
Merged 3 years ago by tkopecek. Opened 3 years ago by tkopecek.
tkopecek/koji issue1401  into  master

@@ -3293,6 +3293,8 @@ 

      parser.add_option("--type", help=_("List builds of this type."))

      parser.add_option("--prefix", help=_("Only builds starting with this prefix"))

      parser.add_option("--pattern", help=_("Only list builds matching this GLOB pattern"))

+     parser.add_option("--cg",

+                       help=_("Only list builds imported by matching content generator name"))

      parser.add_option("--source", help=_("Only builds where the source field matches "

                                           "(glob pattern)"))

      parser.add_option("--owner", help=_("List builds built by this owner"))
@@ -3313,6 +3315,8 @@ 

          value = getattr(options, key)

          if value is not None:

              opts[key] = value

+     if options.cg:

+         opts['cgID'] = options.cg

      if options.package:

          try:

              opts['packageID'] = int(options.package)

file modified
+8 -1
@@ -11579,7 +11579,7 @@ 

                     volumeID=None, source=None,

                     createdBefore=None, createdAfter=None,

                     completeBefore=None, completeAfter=None, type=None, typeInfo=None,

-                    queryOpts=None, pattern=None):

+                    queryOpts=None, pattern=None, cgID=None):

          """

          Return a list of builds that match the given parameters

  
@@ -11593,6 +11593,7 @@ 

          :param str prefix: only builds whose package name starts with that prefix

          :param str pattern: only builds whose nvr matches the glob pattern

          :param int state: only builds in the given state

+         :param int|str cgID: only build from given content generator

  

          Timestamp filter parameters

              - these limit the results to builds where the corresponding
@@ -11722,6 +11723,12 @@ 

              if not isinstance(completeAfter, str):

                  completeAfter = datetime.datetime.fromtimestamp(completeAfter).isoformat(' ')

              clauses.append('build.completion_time > %(completeAfter)s')

+         if cgID:

+             cgID = lookup_name('content_generator', cgID, strict=False)

+             if not cgID:

+                 return []

+             cgID = cgID['id']

+             clauses.append('build.cg_id = %(cgID)s')

          if type is None:

              pass

          elif type == 'maven':

Maybe it could also be a CG name? We don't have a getCG API yet...

Maybe it could also be a CG name? We don't have a getCG API yet...

Do you mean that we should convert it to ID on server instead here? I've tried to mimick behaviour for other filters which check the existence on client side. But not sure if it is really helpful as server-side check would be quicker.

Maybe it could also be a CG name? We don't have a getCG API yet...

Do you mean that we should convert it to ID on server instead here? I've tried to mimick behaviour for other filters which check the existence on client side. But not sure if it is really helpful as server-side check would be quicker.

Yeah, I thought it might be similar with lookup_name(btype) for example, but on the cli side, the isinstance() check is still needed

rebased onto 24f5f732f82118c6b5562a0c4574c7ba95d8a9e4

3 years ago

Metadata Update from @julian8628:
- Pull-request tagged with: testing-ready

3 years ago

With non-existing cg_id following error is returned

unsupported content generator: None

to be consistent with other filters empty list should be returned

rebased onto 73399e5

3 years ago

rebased onto 0f10bbd6c467cf38ccd51cca3f5193a452fc7620

3 years ago

rebased onto 6dd5764

3 years ago

Metadata Update from @mfilip:
- Pull-request tagged with: testing-done

3 years ago

Commit 52ae561 fixes this pull-request

Pull-Request has been merged by tkopecek

3 years ago