Skip to content

Commit

Permalink
Add pre-2024 diversity stats (2018 & 2022)
Browse files Browse the repository at this point in the history
  • Loading branch information
SamLR committed Dec 13, 2024
1 parent ac26352 commit 136b27c
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 0 deletions.
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 %}

0 comments on commit 136b27c

Please sign in to comment.