Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add pre-2024 diversity stats (2018 & 2022) #1785

Merged
merged 1 commit into from
Dec 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions apps/base/about.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
although some legacy content remains here.
"""

import json

from flask import (
redirect,
render_template,
Expand All @@ -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/<int:year>")
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}")


Expand Down
2 changes: 2 additions & 0 deletions templates/about/diversity.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,6 @@ catalyst for a big change.

## The stats

* [2018](diversity/2018)
* [2022](diversity/2022)
* [2024](diversity/2024)
46 changes: 46 additions & 0 deletions templates/about/diversity/pre-2024-stats.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{% extends "about/template.html" %}
{% block title %}Diversity stats {{year}}{% endblock %}
{% block body %}
{% macro stats_table(data, title) %}
<h3>{{ title }}</h3>

{% set total = data.values() | sum %}
<table class="table">
<thead><tr>
<th></th>
<th>Count</th>
<th>Percent of respondents</th>
</tr></thead>
<tbody>
{% for category, count in data.items() %}
<tr>
<td>{{ category | capitalize }}{% if category == "" %}No response{% endif %}</td>
<td>{{ count }}</td>
<td>{{ (100 * count/total) | round | int }}%</td>
</tr>
{% endfor %}
<tr>
<th>Total</th>
<td>{{ total }}</td>
<td>{{ (100 * total/total) | round | int }}%</td>
</tr>
</tbody>
</table>
{% endmacro %}

<h2>Diversity stats for {{year}}</h2>

<h3>Note on limitations</h3>
<p>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'.</p>

<p>All questions were optional so totals may not be consistent between categories.</p>

<p>Prior to 2024 there was no tracking of reviewer or speaker data.</p>

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

{% endblock %}
Loading