From 70a6221b0c7529b75295e6d3c4a66b98b1f100c0 Mon Sep 17 00:00:00 2001 From: Mark Veidemanis Date: Thu, 21 Jul 2022 13:53:02 +0100 Subject: [PATCH] Group items in meta by field --- core/templates/ui/insights/meta.html | 56 +++------------------------- core/views/dynamic/insights.py | 9 ++--- 2 files changed, 10 insertions(+), 55 deletions(-) diff --git a/core/templates/ui/insights/meta.html b/core/templates/ui/insights/meta.html index f1c55ad..9cfb858 100644 --- a/core/templates/ui/insights/meta.html +++ b/core/templates/ui/insights/meta.html @@ -1,63 +1,19 @@
- {% for item in meta %} - + {% for key,items in meta.items %} + +
{{ key }}
- {% if 'ts' in item %} + {% for item in items %} - - {% endif %} - {% if 'nick' in item %} - - - - - {% endif %} - {% if 'ident' in item %} - - - - - {% endif %} - {% if 'host' in item %} - - - - - {% endif %} - {% if 'realname' in item %} - - - - - {% endif %} - {% if 'status' in item %} - - - - - {% endif %} - {% if 'server' in item %} - - - - - {% endif %} - {% if 'channel' in item %} - - - - - {% endif %} + {% endfor %}
ts -

{{ item.date }}

-

{{ item.time }}

+ {{ item }}
nick{{ item.nick }}
ident{{ item.ident }}
host{{ item.host }}
realname{{ item.realname }}
status{{ item.status }}
server{{ item.server }}
channel{{ item.channel }}
-
{% endfor %}
diff --git a/core/views/dynamic/insights.py b/core/views/dynamic/insights.py index 972d74d..a177329 100644 --- a/core/views/dynamic/insights.py +++ b/core/views/dynamic/insights.py @@ -107,16 +107,15 @@ class InsightsMeta(LoginRequiredMixin, APIView): if k in ["ts", "time", "date", "id"]: continue unique_values[nick][k].add(v) - meta_dedup = [] + meta_dedup = {} for x in meta: nick = x["nick"] - meta_l2 = {} for k, v in x.items(): if v in unique_values[nick][k]: - meta_l2[k] = v + if k not in meta_dedup: + meta_dedup[k] = set() + meta_dedup[k].add(v) unique_values[nick][k].remove(v) - if not set(meta_l2.keys()).issubset(set(["ts", "time", "date", "id"])): - meta_dedup.append(meta_l2) context = {"net": net, "nicks": nicks, "meta": meta_dedup} return render(request, self.template_name, context)