]> git.ipfire.org Git - thirdparty/patchwork.git/commit
REST: Resolve performance issues with tags
authorStephen Finucane <stephen@that.guru>
Fri, 28 Oct 2016 18:02:41 +0000 (19:02 +0100)
committerStephen Finucane <stephen@that.guru>
Fri, 23 Dec 2016 23:38:07 +0000 (23:38 +0000)
commitdc787e93a771addddf0f6ceff5d853240d217f2b
treee71d230169e4fa33d52e574b9be87bbb7ce0517a
parent9edc08a648f67067da80a5a71f7a3a1c3064e5d4
REST: Resolve performance issues with tags

The list comprehension used to generate a list of tags resulted in a
significant number of duplicated queries. Resolve this by copying the
approach taken to minimize patch queries in the UI.

This changes the output of the response in two ways. First, counts for
all tag patches are now shown, even if the count is 0. Secondly, a
dictionary is returned, with the tag name as the key, rather than a
list. As such, the output for a typical patch is transformed from:

    [
      {
        'name': 'Reviewed-by',
        'count': 1
      }
    ]

to

    {
      'Reviewed-by': 1
      'Acked-by': 0,
      'Tested-by': 0
    }

How this is achieved is a little hacky, but reworked tags are on the
post-v2.0 which will allow this to be resolved.

Signed-off-by: Stephen Finucane <stephen@that.guru>
patchwork/api/patch.py
patchwork/models.py
patchwork/tests/test_rest_api.py