File tree Expand file tree Collapse file tree 3 files changed +60
-0
lines changed Expand file tree Collapse file tree 3 files changed +60
-0
lines changed Original file line number Diff line number Diff line change 5
5
although some legacy content remains here.
6
6
"""
7
7
8
+ import json
9
+
8
10
from flask import (
9
11
redirect ,
10
12
render_template ,
@@ -24,8 +26,18 @@ def branding():
24
26
def page (page_name : str ):
25
27
return render_markdown (f"about/{ page_name } " , page_name = page_name )
26
28
29
+
27
30
@base .route ("/about/diversity/<int:year>" )
28
31
def yearly_diversity_stats (year : int ):
32
+ if year in (2018 , 2022 ):
33
+ with open (f"exports/{ year } /public/UserDiversity.json" , "r" ) as raw_data :
34
+ data = json .load (raw_data )
35
+
36
+ return render_template (
37
+ f"about/diversity/pre-2024-stats.html" ,
38
+ year = year ,
39
+ data = data ["diversity" ],
40
+ )
29
41
return render_markdown (f"about/diversity/{ year } " )
30
42
31
43
Original file line number Diff line number Diff line change @@ -24,4 +24,6 @@ catalyst for a big change.
24
24
25
25
## The stats
26
26
27
+ * [ 2018] ( diversity/2018 )
28
+ * [ 2022] ( diversity/2022 )
27
29
* [ 2024] ( diversity/2024 )
Original file line number Diff line number Diff line change
1
+ {% extends "about/template.html" %}
2
+ {% block title %}Diversity stats {{year}}{% endblock %}
3
+ {% block body %}
4
+ {% macro stats_table(data, title) %}
5
+ < h3 > {{ title }}</ h3 >
6
+
7
+ {% set total = data.values() | sum %}
8
+ < table class ="table ">
9
+ < thead > < tr >
10
+ < th > </ th >
11
+ < th > Count</ th >
12
+ < th > Percent of respondents</ th >
13
+ </ tr > </ thead >
14
+ < tbody >
15
+ {% for category, count in data.items() %}
16
+ < tr >
17
+ < td > {{ category | capitalize }}{% if category == "" %}No response{% endif %}</ td >
18
+ < td > {{ count }}</ td >
19
+ < td > {{ (100 * count/total) | round | int }}%</ td >
20
+ </ tr >
21
+ {% endfor %}
22
+ < tr >
23
+ < th > Total</ th >
24
+ < td > {{ total }}</ td >
25
+ < td > {{ (100 * total/total) | round | int }}%</ td >
26
+ </ tr >
27
+ </ tbody >
28
+ </ table >
29
+ {% endmacro %}
30
+
31
+ < h2 > Diversity stats for {{year}}</ h2 >
32
+
33
+ < h3 > Note on limitations</ h3 >
34
+ < p > This data is compiled from self reporting via free-text fields. Where obvious
35
+ classification can be made it has been (e.g. for age '22' -> '15-24') but if such a
36
+ classification cannot be made they've been grouped as 'other'.</ p >
37
+
38
+ < p > All questions were optional so totals may not be consistent between categories.</ p >
39
+
40
+ < p > Prior to 2024 there was no tracking of reviewer or speaker data.</ p >
41
+
42
+ {{ stats_table(data["sex"], "Sex") }}
43
+ {{ stats_table(data["ethnicity"], "Ethnicity") }}
44
+ {{ stats_table(data["age"], "Age") }}
45
+
46
+ {% endblock %}
You can’t perform that action at this time.
0 commit comments