Print the number of users on the channels in Insights

This commit is contained in:
Mark Veidemanis 2022-07-21 13:52:27 +01:00
parent e4487c8bf0
commit bb8f6d119e
Signed by: m
GPG Key ID: 5ACFCEED46C0904F
2 changed files with 9 additions and 3 deletions

View File

@ -1,3 +1,5 @@
{% load index %}
<div id="channels"> <div id="channels">
<div class="content" style="max-height: 30em; overflow: auto;"> <div class="content" style="max-height: 30em; overflow: auto;">
<table class="table is-fullwidth is-hoverable"> <table class="table is-fullwidth is-hoverable">
@ -13,6 +15,11 @@
class="button is-small"> class="button is-small">
{{ chan }} {{ chan }}
</span> </span>
{% if chan in num_users %}
<span class="tag">
{{ num_users|index:chan }}
</span>
{% endif %}
</td> </td>
</tr> </tr>
{% endfor %} {% endfor %}

View File

@ -43,12 +43,11 @@ class InsightsChannels(LoginRequiredMixin, APIView):
return HttpResponse("No nick") return HttpResponse("No nick")
net = request.data["net"] net = request.data["net"]
nick = request.data["nick"] nick = request.data["nick"]
print("Insights channels item", nick)
chans = get_chans(net, [nick]) chans = get_chans(net, [nick])
print("GET CHANS", chans) num_users = annotate_num_users(net, chans)
if not chans: if not chans:
return HttpResponseForbidden() return HttpResponseForbidden()
context = {"net": net, "nick": nick, "chans": chans} context = {"net": net, "nick": nick, "chans": chans, "num_users": num_users}
return render(request, self.template_name, context) return render(request, self.template_name, context)