Skip to content
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
143 changes: 143 additions & 0 deletions portal/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
CACHE_KEY_DONATION_TOWARDS_GOAL_PERCENT,
CACHE_KEY_DONATIONS_TOTAL_AMOUNT,
CACHE_KEY_DONORS_COUNT,
CACHE_KEY_HISTORICAL_COMPARISON,
CACHE_KEY_SPONSORSHIP_BREAKDOWN,
CACHE_KEY_SPONSORSHIP_COMMITTED,
CACHE_KEY_SPONSORSHIP_COMMITTED_COUNT,
Expand All @@ -27,6 +28,8 @@
CACHE_KEY_VOLUNTEER_SIGNUPS_COUNT,
DONATION_GOAL_AMOUNT,
DONATIONS_GOAL,
HISTORICAL_STATS,
PROPOSALS_2025_COUNT,
SPONSORSHIP_GOAL,
SPONSORSHIP_GOAL_AMOUNT,
STATS_CACHE_TIMEOUT,
Expand All @@ -49,6 +52,7 @@ def get_stats_cached_values():
stats_dict.update(get_sponsorships_stats_dict())
stats_dict.update(get_donations_stats_dict())
stats_dict.update(get_attendee_stats_dict())
stats_dict[CACHE_KEY_HISTORICAL_COMPARISON] = get_historical_comparison_data()
return stats_dict


Expand Down Expand Up @@ -610,3 +614,142 @@ def get_attendee_stats_dict():
stats_dict = {}
stats_dict[CACHE_KEY_ATTENDEE_COUNT] = get_attendee_count_cache()
return stats_dict


def get_historical_comparison_data():
"""
Returns historical comparison data for charts showing progress over the years.
Combines hardcoded historical data with current year's data.
"""
historical_comparison = cache.get(CACHE_KEY_HISTORICAL_COMPARISON)
if not historical_comparison:
# Get current year data
current_registrations = get_attendee_count_cache()
current_sponsors = get_sponsorship_total_count_stats_cache()
current_sponsorship_amount = get_sponsorship_committed_amount_stats_cache()
current_donors = get_donors_count_cache()
current_donation_amount = get_total_donations_amount_cache()

# Build comparison data structure
historical_comparison = []

# Registrations comparison
historical_comparison.append(
{
"title": "Registrations Over the Years",
"columns": [["string", "Year"], ["number", "Registrations"]],
"data": [
["2023", HISTORICAL_STATS["2023"]["registrations"]],
["2024", HISTORICAL_STATS["2024"]["registrations"]],
["2025", current_registrations],
],
"chart_id": "registrations_comparison",
"chart_type": "bar",
}
)

# Proposals comparison
historical_comparison.append(
{
"title": "Proposals Over the Years",
"columns": [["string", "Year"], ["number", "Proposals"]],
"data": [
["2023", HISTORICAL_STATS["2023"]["proposals"]],
["2024", HISTORICAL_STATS["2024"]["proposals"]],
["2025", PROPOSALS_2025_COUNT],
],
"chart_id": "proposals_comparison",
"chart_type": "bar",
}
)

# Sponsors comparison
historical_comparison.append(
{
"title": "Number of Sponsors Over the Years",
"columns": [["string", "Year"], ["number", "Sponsors"]],
"data": [
["2023", HISTORICAL_STATS["2023"]["sponsors"]],
["2024", HISTORICAL_STATS["2024"]["sponsors"]],
["2025", current_sponsors],
],
"chart_id": "sponsors_comparison",
"chart_type": "bar",
}
)

# Sponsorship amount comparison
historical_comparison.append(
{
"title": "Sponsorship Amount Over the Years",
"columns": [["string", "Year"], ["number", "Amount (USD)"]],
"data": [
["2023", HISTORICAL_STATS["2023"]["sponsorship_amount"]],
["2024", HISTORICAL_STATS["2024"]["sponsorship_amount"]],
["2025", current_sponsorship_amount],
],
"chart_id": "sponsorship_amount_comparison",
"chart_type": "bar",
}
)

# Individual donations comparison
historical_comparison.append(
{
"title": "Number of Individual Donors Over the Years",
"columns": [["string", "Year"], ["number", "Donors"]],
"data": [
["2023", HISTORICAL_STATS["2023"]["donors"]],
["2024", HISTORICAL_STATS["2024"]["donors"]],
["2025", current_donors],
],
"chart_id": "donors_comparison",
"chart_type": "bar",
}
)

# Donation amount comparison
historical_comparison.append(
{
"title": "Donation Amount Over the Years",
"columns": [["string", "Year"], ["number", "Amount (USD)"]],
"data": [
["2023", HISTORICAL_STATS["2023"]["donation_amount"]],
["2024", HISTORICAL_STATS["2024"]["donation_amount"]],
["2025", current_donation_amount],
],
"chart_id": "donation_amount_comparison",
"chart_type": "bar",
}
)

# Total proceeds comparison
historical_comparison.append(
{
"title": "Total Proceeds Over the Years",
"columns": [["string", "Year"], ["number", "Amount (USD)"]],
"data": [
[
"2023",
HISTORICAL_STATS["2023"]["sponsorship_amount"]
+ HISTORICAL_STATS["2023"]["donation_amount"],
],
[
"2024",
HISTORICAL_STATS["2024"]["sponsorship_amount"]
+ HISTORICAL_STATS["2024"]["donation_amount"],
],
["2025", current_sponsorship_amount + current_donation_amount],
],
"chart_id": "proceeds_comparison",
"chart_type": "bar",
}
)

cache.set(
CACHE_KEY_HISTORICAL_COMPARISON,
historical_comparison,
STATS_CACHE_TIMEOUT,
)

return historical_comparison
27 changes: 27 additions & 0 deletions portal/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,31 @@

CACHE_KEY_ATTENDEE_COUNT = "attendee_count"

# Historical data for comparison charts
CACHE_KEY_HISTORICAL_COMPARISON = "historical_comparison"

# Historical data from past PyLadiesCon events
# Data source: https://conference.pyladies.com/2024-pyladiescon-ends/
HISTORICAL_STATS = {
"2023": {
"registrations": 600,
"proposals": 164,
"sponsors": 8,
"sponsorship_amount": 10500,
"donors": 58,
"donation_amount": 650,
},
"2024": {
"registrations": 732,
"proposals": 192,
"sponsors": 11,
"sponsorship_amount": 10000,
"donors": 105,
"donation_amount": 1520,
},
}

# Current year proposals count (not stored in database)
PROPOSALS_2025_COUNT = 194

BASE_PRETIX_URL = "https://pretix.eu/api/v1/"
40 changes: 40 additions & 0 deletions templates/portal/historical_comparison_charts.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{% comment %}
Historical comparison charts for PyLadiesCon stats across years
Uses Google Charts to display bar charts comparing metrics from 2023, 2024, and 2025
{% endcomment %}
{% for comparison in stats.historical_comparison %}
var data_{{ comparison.chart_id }} = new google.visualization.DataTable();
{% for column in comparison.columns %}
data_{{ comparison.chart_id }}.addColumn('{{ column.0 }}', '{{ column.1 }}');
{% endfor %}
data_{{ comparison.chart_id }}.addRows([
{% for row in comparison.data %}
['{{ row.0 }}', {{ row.1 }}]
{% if not forloop.last %}
,
{% endif %}
{% endfor %}
]);
var options_{{ comparison.chart_id }} = {
title: '{{ comparison.title }}',
chartArea: { width: '70%' },
hAxis: {
title: 'Year',
minValue: 0
},
vAxis: {
title: '{{ comparison.columns.1.1 }}'
},
colors: ['#7C5BC8'],
legend: { position: 'none' },
animation: {
startup: true,
duration: 1000,
easing: 'out'
}
};
var chart_{{ comparison.chart_id }} = new google.visualization.ColumnChart(
document.getElementById('{{ comparison.chart_id }}')
);
chart_{{ comparison.chart_id }}.draw(data_{{ comparison.chart_id }}, options_{{ comparison.chart_id }});
{% endfor %}
26 changes: 26 additions & 0 deletions templates/portal/stats.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,14 @@
function drawChart() {
{% include "sponsorship/sponsorship_charts.html" %}
{% include "volunteer/volunteer_charts.html" %}
{% include "portal/historical_comparison_charts.html" %}
}
</script>
<style>
.chart-container {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this be added to /portal/static/styles.css?

height: 300px;
}
</style>
{% endblock extra_head %}
{% block body %}
{% endblock body %}
Expand Down Expand Up @@ -53,5 +59,25 @@ <h3 class="mb-2">
</div>
</div>
{% include "volunteer/volunteer_stats.html" %}
<!-- Historical Comparison Section -->
<div class="row mt-5">
<div class="col-12">
<h3 class="pb-2 border-bottom">
<i class="bi bi-graph-up"></i> Historical Comparison
</h3>
</div>
</div>
<div class="row g-4 mt-2">
{% for comparison in stats.historical_comparison %}
<div class="col-md-6">
<div class="card h-100">
<div class="card-body">
<div id="{{ comparison.chart_id }}" class="chart-container">
</div>
</div>
</div>
</div>
{% endfor %}
</div>
</div>
{% endblock content %}