[PATCH] Beautify check counts in the patch list view

Ali Alnubani alialnu at mellanox.com
Tue Jan 8 23:52:53 AEDT 2019


Hi all,

An example of what this patch does can be seen on http://patches.dpdk.org/project/dpdk/list/.

If you have any suggestions or better approaches to improve the code, please let me know.

Thanks,
Ali

> -----Original Message-----
> From: Patchwork <patchwork-
> bounces+alialnu=mellanox.com at lists.ozlabs.org> On Behalf Of Ali Alnubani
> Sent: Tuesday, January 8, 2019 2:39 PM
> To: patchwork at lists.ozlabs.org
> Cc: Thomas Monjalon <thomas at monjalon.net>
> Subject: [PATCH] Beautify check counts in the patch list view
> 
> This patch [1] adds colors to the checks in the patch list view.
> The colors are set based on the check's priority, with FAILURE having the
> highest priority, followed by WARNING, and then SUCCESS.
> Only the check with the highest priority and non-zero count will be colored.
> This is to make failures and warnings more visible.
> 
> The patch also [2] replaces zero counts with a '-' for FAILUREs and
> WARNINGs.
> The SUCCESS count will only be replaced by a '-'
> when all other checks have zero counts too.
> 
> Suggested-by: Thomas Monjalon <thomas at monjalon.net>
> Signed-off-by: Ali Alnubani <alialnu at mellanox.com>
> ---
>  htdocs/css/style.css            | 21 +++++++++++++++++++++
>  patchwork/templatetags/patch.py | 26 +++++++++++++++++++++++++-
>  2 files changed, 46 insertions(+), 1 deletion(-)
> 
> diff --git a/htdocs/css/style.css b/htdocs/css/style.css index
> 6b2a80a..1c95174 100644
> --- a/htdocs/css/style.css
> +++ b/htdocs/css/style.css
> @@ -240,6 +240,27 @@ table.patchmeta tr th, table.patchmeta tr td {
>  	text-decoration: underline;
>  }
> 
> +.patchlistchecks {
> +	border-radius: 7px;
> +	padding: 3px;
> +}
> +
> +.patchlistchecks.success {
> +	background-color: #82ca9d;
> +}
> +
> +.patchlistchecks.warning {
> +	background-color: #ffc95e;
> +}
> +
> +.patchlistchecks.fail {
> +	background-color: #ff5555;
> +}
> +
> +.patchlistchecks.empty {
> +	padding: 4px;
> +}
> +
>  .checks .state {
>  	font-weight: bold;
>  	color: #ddd;
> diff --git a/patchwork/templatetags/patch.py
> b/patchwork/templatetags/patch.py index 5d387a4..c57a642 100644
> --- a/patchwork/templatetags/patch.py
> +++ b/patchwork/templatetags/patch.py
> @@ -36,9 +36,33 @@ def patch_checks(patch):
>      titles = ['Success', 'Warning', 'Fail']
>      counts = patch.check_count
> 
> +    check_color = {Check.STATE_SUCCESS: "success",
> +            Check.STATE_WARNING: "warning",
> +            Check.STATE_FAIL: "fail"}
> +
> +    check_elements = []
> +    if any(counts[state] for state in required):
> +        for state in required:
> +            if counts[state] > 0 and (state == Check.STATE_FAIL or \
> +                    (state == Check.STATE_WARNING and counts[Check.STATE_FAIL]
> == 0) or \
> +                    (state == Check.STATE_SUCCESS and
> counts[Check.STATE_WARNING] == 0 and \
> +                    counts[Check.STATE_FAIL] == 0)):
> +                check_elements.append('<span class=\"patchlistchecks
> {}\">{}</span>'.format( \
> +                        check_color[state],
> +                        str(counts[state])))
> +            else:
> +                if state == Check.STATE_SUCCESS:
> +                    check_elements.append('<span
> class=\"patchlistchecks\">{}</span>'.format( \
> +                            str(counts[state])))
> +                else:
> +                    check_elements.append('<span class=\"patchlistchecks\">-
> </span>')
> +    else:
> +        check_elements = ['<span class=\"patchlistchecks empty\">-
> </span>'.format(str(counts[state])) \
> +                for state in required]
> +
>      return mark_safe('<span title="%s">%s</span>' % (
>          ' / '.join(titles),
> -        ' '.join([str(counts[state]) for state in required])))
> +        ''.join(check_elements)))
> 
> 
>  @register.filter
> --
> 2.11.0
> 
> _______________________________________________
> Patchwork mailing list
> Patchwork at lists.ozlabs.org
> https://lists.ozlabs.org/listinfo/patchwork


More information about the Patchwork mailing list