Group items in meta by field

This commit is contained in:
2022-07-21 13:53:02 +01:00
parent 8710c66e05
commit 70a6221b0c
2 changed files with 10 additions and 55 deletions

View File

@@ -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)