From 551b49b903cfdfe8e63de58de788b67b320aaf11 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Mon, 4 Oct 2021 11:14:50 -0700 Subject: [PATCH] Adds works chart and updates colors --- .../settings/dashboard/dashboard.html | 11 ++++- .../dashboard/registration_chart.html | 4 +- .../settings/dashboard/status_chart.html | 4 +- .../settings/dashboard/user_chart.html | 40 +++++++++---------- .../settings/dashboard/works_chart.html | 21 ++++++++++ bookwyrm/views/admin/dashboard.py | 11 +++++ 6 files changed, 63 insertions(+), 28 deletions(-) create mode 100644 bookwyrm/templates/settings/dashboard/works_chart.html diff --git a/bookwyrm/templates/settings/dashboard/dashboard.html b/bookwyrm/templates/settings/dashboard/dashboard.html index cd0ddc842..445bf2992 100644 --- a/bookwyrm/templates/settings/dashboard/dashboard.html +++ b/bookwyrm/templates/settings/dashboard/dashboard.html @@ -102,6 +102,12 @@ +
+

{% trans "User signup activity" %}

+
+ +
+

{% trans "Status activity" %}

@@ -109,9 +115,9 @@
-

{% trans "User signup activity" %}

+

{% trans "Works created" %}

- +
@@ -124,4 +130,5 @@ {% include 'settings/dashboard/user_chart.html' %} {% include 'settings/dashboard/status_chart.html' %} {% include 'settings/dashboard/registration_chart.html' %} +{% include 'settings/dashboard/works_chart.html' %} {% endblock %} diff --git a/bookwyrm/templates/settings/dashboard/registration_chart.html b/bookwyrm/templates/settings/dashboard/registration_chart.html index e98a0f18f..3b258fec8 100644 --- a/bookwyrm/templates/settings/dashboard/registration_chart.html +++ b/bookwyrm/templates/settings/dashboard/registration_chart.html @@ -8,8 +8,8 @@ var registerStats = new Chart( labels: [{% for label in register_stats.labels %}"{{ label }}",{% endfor %}], datasets: [{ label: '{% trans "Registrations" %}', - backgroundColor: 'rgb(75, 192, 192)', - borderColor: 'rgb(75, 192, 192)', + backgroundColor: 'hsl(171, 100%, 41%)', + borderColor: 'hsl(171, 100%, 41%)', data: {{ register_stats.total }}, }] }, diff --git a/bookwyrm/templates/settings/dashboard/status_chart.html b/bookwyrm/templates/settings/dashboard/status_chart.html index 5e1045fce..a59036a51 100644 --- a/bookwyrm/templates/settings/dashboard/status_chart.html +++ b/bookwyrm/templates/settings/dashboard/status_chart.html @@ -9,8 +9,8 @@ var statusStats = new Chart( labels: [{% for label in status_stats.labels %}"{{ label }}",{% endfor %}], datasets: [{ label: '{% trans "Statuses posted" %}', - backgroundColor: 'rgb(255, 99, 132)', - borderColor: 'rgb(255, 99, 132)', + backgroundColor: 'hsl(141, 71%, 48%)', + borderColor: 'hsl(141, 71%, 48%)', data: {{ status_stats.total }}, }] }, diff --git a/bookwyrm/templates/settings/dashboard/user_chart.html b/bookwyrm/templates/settings/dashboard/user_chart.html index 33be28f7e..a8d356bb8 100644 --- a/bookwyrm/templates/settings/dashboard/user_chart.html +++ b/bookwyrm/templates/settings/dashboard/user_chart.html @@ -1,29 +1,25 @@ {% load i18n %} diff --git a/bookwyrm/templates/settings/dashboard/works_chart.html b/bookwyrm/templates/settings/dashboard/works_chart.html new file mode 100644 index 000000000..c65014e98 --- /dev/null +++ b/bookwyrm/templates/settings/dashboard/works_chart.html @@ -0,0 +1,21 @@ +{% load i18n %} + + diff --git a/bookwyrm/views/admin/dashboard.py b/bookwyrm/views/admin/dashboard.py index 27edc3438..b1aedecf7 100644 --- a/bookwyrm/views/admin/dashboard.py +++ b/bookwyrm/views/admin/dashboard.py @@ -73,6 +73,16 @@ class Dashboard(View): } ) + works_chart = Chart( + queryset=models.Work.objects, + queries = { + "total": lambda q, s, e: q.filter( + created_date__gt=s, + created_date__lte=e, + ).count() + } + ) + data = { "start": start.strftime("%Y-%m-%d"), "end": end.strftime("%Y-%m-%d"), @@ -90,6 +100,7 @@ class Dashboard(View): "user_stats": user_chart.get_chart(start, end, interval), "status_stats": status_chart.get_chart(start, end, interval), "register_stats": register_chart.get_chart(start, end, interval), + "works_stats": works_chart.get_chart(start, end, interval), } return TemplateResponse(request, "settings/dashboard/dashboard.html", data)