From a7b35c68837d368ad5e502b6f06a7cbfdfeb1fce Mon Sep 17 00:00:00 2001 From: stupidcomputer Date: Fri, 21 Jun 2024 22:54:34 -0500 Subject: [PATCH] add a stats page --- .../explorer/templates/explorer/stats.html | 28 +++++++++++++++++++ franklincce/explorer/urls.py | 1 + franklincce/explorer/views.py | 16 +++++++++++ 3 files changed, 45 insertions(+) create mode 100644 franklincce/explorer/templates/explorer/stats.html diff --git a/franklincce/explorer/templates/explorer/stats.html b/franklincce/explorer/templates/explorer/stats.html new file mode 100644 index 0000000..83ebf61 --- /dev/null +++ b/franklincce/explorer/templates/explorer/stats.html @@ -0,0 +1,28 @@ +{% extends "explorer/base.html" %} + +{% block content %} + +
+

Explorer statistics

+ +

Total bills: {{ all }}

+ +

Red Senate Bills: {{ red_senate }}

+ +

White Senate Bills: {{ white_senate }}

+ +

Blue Senate Bills: {{ blue_senate }}

+ +

Red House Bills: {{ red_house }}

+ +

White House Bills: {{ white_house }}

+ +

Blue House Bills: {{ blue_house }}

+ +

Red General Assembly Bills: {{ red_ga }}

+ +

White General Assembly Bills: {{ white_ga }}

+ +

Blue General Assembly Bills: {{ blue_ga }}

+
+{% endblock content %} diff --git a/franklincce/explorer/urls.py b/franklincce/explorer/urls.py index e7758c6..a2580d2 100644 --- a/franklincce/explorer/urls.py +++ b/franklincce/explorer/urls.py @@ -5,6 +5,7 @@ from . import views urlpatterns = [ path("", views.index, name="index"), path("all/", views.all, name="all"), + path("stats/", views.stats, name="stats"), path("legislation//", views.view_legislation, name="viewleg"), path("conference//", views.view_conference, name="viewconf"), ] diff --git a/franklincce/explorer/views.py b/franklincce/explorer/views.py index 0ce1afa..feb0db8 100644 --- a/franklincce/explorer/views.py +++ b/franklincce/explorer/views.py @@ -37,3 +37,19 @@ def view_conference(request, conference_id): "sample": results[0] } return render(request, "explorer/conference.html", context) + +def stats(request): + all_legislation = len(LegislativeText.objects.all()) + context = { + "all": all_legislation, + "red_senate": len(LegislativeText.objects.filter(assembly="RSB")), + "blue_senate": len(LegislativeText.objects.filter(assembly="BSB")), + "white_senate": len(LegislativeText.objects.filter(assembly="WSB")), + "red_house": len(LegislativeText.objects.filter(assembly="RHB")), + "blue_house": len(LegislativeText.objects.filter(assembly="BHB")), + "white_house": len(LegislativeText.objects.filter(assembly="WHB")), + "red_ga": len(LegislativeText.objects.filter(assembly="RGA")), + "blue_ga": len(LegislativeText.objects.filter(assembly="BGA")), + "white_ga": len(LegislativeText.objects.filter(assembly="WGA")), + } + return render(request, "explorer/stats.html", context)