diff --git a/apps/base/about.py b/apps/base/about.py index 644e4110c..1d981598d 100644 --- a/apps/base/about.py +++ b/apps/base/about.py @@ -5,6 +5,8 @@ although some legacy content remains here. """ +import json + from flask import ( redirect, render_template, @@ -24,8 +26,18 @@ def branding(): def page(page_name: str): return render_markdown(f"about/{page_name}", page_name=page_name) + @base.route("/about/diversity/") def yearly_diversity_stats(year: int): + if year in (2018, 2022): + with open(f"exports/{year}/public/UserDiversity.json", "r") as raw_data: + data = json.load(raw_data) + + return render_template( + f"about/diversity/pre-2024-stats.html", + year=year, + data=data["diversity"], + ) return render_markdown(f"about/diversity/{year}") diff --git a/templates/about/diversity.md b/templates/about/diversity.md index 7fc9b375e..5fc27a2ed 100644 --- a/templates/about/diversity.md +++ b/templates/about/diversity.md @@ -24,4 +24,6 @@ catalyst for a big change. ## The stats +* [2018](diversity/2018) +* [2022](diversity/2022) * [2024](diversity/2024) diff --git a/templates/about/diversity/pre-2024-stats.html b/templates/about/diversity/pre-2024-stats.html new file mode 100644 index 000000000..eb62125c3 --- /dev/null +++ b/templates/about/diversity/pre-2024-stats.html @@ -0,0 +1,46 @@ +{% extends "about/template.html" %} +{% block title %}Diversity stats {{year}}{% endblock %} +{% block body %} +{% macro stats_table(data, title) %} +

{{ title }}

+ +{% set total = data.values() | sum %} + + + + + + + + {% for category, count in data.items() %} + + + + + + {% endfor %} + + + + + + +
CountPercent of respondents
{{ category | capitalize }}{% if category == "" %}No response{% endif %}{{ count }}{{ (100 * count/total) | round | int }}%
Total{{ total }}{{ (100 * total/total) | round | int }}%
+{% endmacro %} + +

Diversity stats for {{year}}

+ +

Note on limitations

+

This data is compiled from self reporting via free-text fields. Where obvious + classification can be made it has been (e.g. for age '22' -> '15-24') but if such a + classification cannot be made they've been grouped as 'other'.

+ +

All questions were optional so totals may not be consistent between categories.

+ +

Prior to 2024 there was no tracking of reviewer or speaker data.

+ +{{ stats_table(data["sex"], "Sex") }} +{{ stats_table(data["ethnicity"], "Ethnicity") }} +{{ stats_table(data["age"], "Age") }} + +{% endblock %}