#1967 don't use full listTags in list-groups call
Merged 4 years ago by tkopecek. Opened 4 years ago by tkopecek.
tkopecek/koji issue1954  into  master

file modified
+14 -4
@@ -2584,23 +2584,33 @@ 

          opts['event'] = event['id']

          event['timestr'] = time.asctime(time.localtime(event['ts']))

          print("Querying at event %(id)i (%(timestr)s)" % event)

-     tags = dict([(x['id'], x['name']) for x in session.listTags()])

      tmp_list = [(x['name'], x) for x in session.getTagGroups(args[0], **opts)]

      tmp_list.sort()

      groups = [x[1] for x in tmp_list]

+ 

+     tags_cache = {}

+     def get_cached_tag(tag_id):

+         if tag_id not in tags_cache:

+             tag = session.getTag(tag_id, strict=False)

+             if tag is None:

+                 tags_cache[tag_id] = tag_id

+             else:

+                 tags_cache[tag_id] = tag['name']

+         return tags_cache[tag_id]

+ 

      for group in groups:

          if len(args) > 1 and group['name'] != args[1]:

              continue

-         print("%s  [%s]" % (group['name'], tags.get(group['tag_id'], group['tag_id'])))

+         print("%s  [%s]" % (group['name'], get_cached_tag(group['tag_id'])))

          groups = [(x['name'], x) for x in group['grouplist']]

          groups.sort()

          for x in [x[1] for x in groups]:

-             x['tag_name'] = tags.get(x['tag_id'], x['tag_id'])

+             x['tag_name'] = get_cached_tag(x['tag_id'])

              print_group_list_req_group(x)

          pkgs = [(x['package'], x) for x in group['packagelist']]

          pkgs.sort()

          for x in [x[1] for x in pkgs]:

-             x['tag_name'] = tags.get(x['tag_id'], x['tag_id'])

+             x['tag_name'] = get_cached_tag(x['tag_id'])

              print_group_list_req_package(x)

  

  

@@ -172,7 +172,14 @@ 

                  pkg['tag_name'] = tags.get(pkg['tag_id'], pkg['tag_id'])

                  expected += "  %(package)s: %(basearchonly)s, %(type)s  [%(tag_name)s]" % pkg + "\n"

  

-         self.session.listTags.return_value = _list_tags

+         #self.session.listTags.return_value = _list_tags

+         def get_tag(tag_id, strict=False):

+             self.assertFalse(strict)

+             for tag in _list_tags:

+                 if tag['id'] == tag_id:

+                     return tag

+             return None

+         self.session.getTag.side_effect = get_tag

          self.session.getTagGroups.return_value = _get_tag_groups

          args = ['fedora26-build']

          args += [query_group] if query_group != '' else []

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

4 years ago

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

4 years ago

Commit f84b3d9 fixes this pull-request

Pull-Request has been merged by tkopecek

4 years ago