Skip to content

Commit 9f38a59

Browse files
Copilotjetzlstorfer
andcommitted
Change "Top Speakers" to show recent speakers from last 15 events instead of all-time frequency
Co-authored-by: jetzlstorfer <[email protected]>
1 parent c839ad4 commit 9f38a59

File tree

1 file changed

+82
-22
lines changed

1 file changed

+82
-22
lines changed

_pages/statistics.md

Lines changed: 82 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -49,18 +49,21 @@ Here you can find insights about our Cloud Native Computing Linz meetups includi
4949
</div>
5050
</div>
5151

52-
### Top 15 Speakers
52+
### Recent Speakers (Last 15 Events)
5353
<div class="chart-container">
5454
<canvas id="topSpeakersChart"></canvas>
5555
<div id="topSpeakersFallback" style="display: none;">
56-
<div class="chart-title">🎤 Top Speakers</div>
56+
<div class="chart-title">🎤 Recent Speakers</div>
5757
<table class="stats-table">
5858
<thead>
59-
<tr><th>Speaker</th><th>Presentations</th><th>Visual</th></tr>
59+
<tr><th>Speaker</th><th>Most Recent Event</th><th>Presentations</th><th>Visual</th></tr>
6060
</thead>
6161
<tbody>
62+
{% comment %} Get the last 15 events (most recent) {% endcomment %}
63+
{% assign recent_events = site.data.events | reverse | slice: 0, 15 %}
6264
{% assign speakers = "" | split: "|" %}
63-
{% for event in site.data.events %}
65+
{% assign speaker_events = "" | split: "|" %}
66+
{% for event in recent_events %}
6467
{% if event.talks %}
6568
{% for talk in event.talks %}
6669
{% if talk.speaker and talk.speaker != '' %}
@@ -76,6 +79,7 @@ Here you can find insights about our Cloud Native Computing Linz meetups includi
7679
{% assign single_speaker = part | strip %}
7780
{% if single_speaker != '' %}
7881
{% assign speakers = speakers | push: single_speaker %}
82+
{% assign speaker_events = speaker_events | push: single_speaker | append: '###' | append: event.date | append: '###' | append: event.title %}
7983
{% endif %}
8084
{% endfor %}
8185
{% endif %}
@@ -86,27 +90,47 @@ Here you can find insights about our Cloud Native Computing Linz meetups includi
8690
{% assign speaker_rows = "" | split: "|" %}
8791
{% for speaker in unique_speakers %}
8892
{% assign count = 0 %}
93+
{% assign most_recent_date = '' %}
94+
{% assign most_recent_title = '' %}
8995
{% for s in speakers %}
9096
{% if s == speaker %}
9197
{% assign count = count | plus: 1 %}
9298
{% endif %}
9399
{% endfor %}
94-
{% assign speaker_rows = speaker_rows | push: speaker | append: '|||' | append: count %}
100+
{% comment %} Find the most recent event for this speaker {% endcomment %}
101+
{% for entry in speaker_events %}
102+
{% assign parts = entry | split: '###' %}
103+
{% if parts[0] == speaker %}
104+
{% if most_recent_date == '' or parts[1] > most_recent_date %}
105+
{% assign most_recent_date = parts[1] %}
106+
{% assign most_recent_title = parts[2] %}
107+
{% endif %}
108+
{% endif %}
109+
{% endfor %}
110+
{% assign speaker_rows = speaker_rows | push: speaker | append: '|||' | append: count | append: '|||' | append: most_recent_date | append: '|||' | append: most_recent_title %}
95111
{% endfor %}
96-
{% assign sorted_speaker_rows = speaker_rows | sort_natural | reverse %}
97-
{% for entry in sorted_speaker_rows %}
112+
{% comment %} Sort by most recent date (descending) {% endcomment %}
113+
{% assign sorted_speaker_rows = speaker_rows | sort %}
114+
{% assign final_sorted_rows = "" | split: "|" %}
115+
{% for row in sorted_speaker_rows %}
116+
{% assign final_sorted_rows = final_sorted_rows | unshift: row %}
117+
{% endfor %}
118+
{% for entry in final_sorted_rows %}
98119
{% assign parts = entry | split: '|||' %}
99120
{% assign speaker = parts[0] %}
100121
{% assign count = parts[1] %}
122+
{% assign event_date = parts[2] %}
123+
{% assign event_title = parts[3] %}
101124
<tr>
102125
<td>{{ speaker }}</td>
126+
<td><strong>{{ event_date }}</strong><br><small>{{ event_title }}</small></td>
103127
<td class="number-cell">{{ count }}</td>
104128
<td><span class="host-bar" style="width: {{ count | times: 10 }}px;"></span> {{ count }}</td>
105129
</tr>
106130
{% endfor %}
107131
</tbody>
108132
</table>
109-
<div class="fallback-note">🎤 This data shows which speakers have presented most often at our events.</div>
133+
<div class="fallback-note">🎤 This shows speakers from our 15 most recent events, sorted by their latest presentation date.</div>
110134
</div>
111135
</div>
112136

@@ -328,9 +352,12 @@ function initializeChartsWithoutTime() {
328352
const hostLabels = sortedHosts.map(([host]) => host);
329353
const hostData = sortedHosts.map(([, count]) => count);
330354

331-
// Top speakers data
355+
// Recent speakers data (from last 15 events)
356+
const recentEvents = events.slice(-15); // Get last 15 events
332357
const speakerCount = {};
333-
events.forEach(event => {
358+
const speakerLastEvent = {};
359+
360+
recentEvents.forEach(event => {
334361
if (event.talks && event.talks.length > 0) {
335362
event.talks.forEach(talk => {
336363
if (talk.speaker) {
@@ -355,21 +382,29 @@ function initializeChartsWithoutTime() {
355382
.map(s => s.trim()) // Trim whitespace
356383
.filter(s => s); // Remove empty strings
357384

358-
// Count each speaker
385+
// Count each speaker and track their most recent event
359386
speakers.forEach(speaker => {
360387
if (speaker) {
361388
speakerCount[speaker] = (speakerCount[speaker] || 0) + 1;
389+
// Update last event if this event is more recent
390+
if (!speakerLastEvent[speaker] || event.date > speakerLastEvent[speaker]) {
391+
speakerLastEvent[speaker] = event.date;
392+
}
362393
}
363394
});
364395
}
365396
});
366397
}
367398
});
368399

369-
// Sort speakers by count desc
400+
// Sort speakers by most recent event date (descending)
370401
const sortedSpeakers = Object.entries(speakerCount)
371-
.sort((a, b) => b[1] - a[1])
372-
.slice(0, 15); // Get top 20 speakers for better visualization
402+
.sort((a, b) => {
403+
const dateA = speakerLastEvent[a[0]];
404+
const dateB = speakerLastEvent[b[0]];
405+
return dateB.localeCompare(dateA); // Most recent first
406+
})
407+
.slice(0, 15); // Get top 15 most recent speakers
373408
const speakerLabels = sortedSpeakers.map(([speaker]) => speaker);
374409
const speakerData = sortedSpeakers.map(([, count]) => count);
375410

@@ -514,7 +549,7 @@ function initializeChartsWithoutTime() {
514549
}
515550
});
516551

517-
// Top Speakers Chart
552+
// Recent Speakers Chart
518553
const speakersCtx = document.getElementById('topSpeakersChart').getContext('2d');
519554
new Chart(speakersCtx, {
520555
type: 'bar',
@@ -530,6 +565,13 @@ function initializeChartsWithoutTime() {
530565
},
531566
options: {
532567
...commonOptions,
568+
plugins: {
569+
...commonOptions.plugins,
570+
title: {
571+
display: true,
572+
text: 'Recent Speakers (Last 15 Events)'
573+
}
574+
},
533575
scales: {
534576
y: {
535577
beginAtZero: true,
@@ -659,9 +701,12 @@ function initializeCharts() {
659701
const hostLabels = sortedHosts.map(([host]) => host);
660702
const hostData = sortedHosts.map(([, count]) => count);
661703

662-
// Top speakers data
704+
// Recent speakers data (from last 15 events)
705+
const recentEvents = events.slice(-15); // Get last 15 events
663706
const speakerCount = {};
664-
events.forEach(event => {
707+
const speakerLastEvent = {};
708+
709+
recentEvents.forEach(event => {
665710
if (event.talks && event.talks.length > 0) {
666711
event.talks.forEach(talk => {
667712
if (talk.speaker) {
@@ -681,21 +726,29 @@ function initializeCharts() {
681726
.map(s => s.trim())
682727
.filter(s => s && s.length > 0);
683728

684-
// Count each speaker
729+
// Count each speaker and track their most recent event
685730
speakers.forEach(speaker => {
686731
if (speaker) {
687732
speakerCount[speaker] = (speakerCount[speaker] || 0) + 1;
733+
// Update last event if this event is more recent
734+
if (!speakerLastEvent[speaker] || event.date > speakerLastEvent[speaker]) {
735+
speakerLastEvent[speaker] = event.date;
736+
}
688737
}
689738
});
690739
}
691740
});
692741
}
693742
});
694743

695-
// Sort speakers by count desc
744+
// Sort speakers by most recent event date (descending)
696745
const sortedSpeakers = Object.entries(speakerCount)
697-
.sort((a, b) => b[1] - a[1])
698-
.slice(0, 20); // Get top 20 speakers for better visualization
746+
.sort((a, b) => {
747+
const dateA = speakerLastEvent[a[0]];
748+
const dateB = speakerLastEvent[b[0]];
749+
return dateB.localeCompare(dateA); // Most recent first
750+
})
751+
.slice(0, 15); // Get top 15 most recent speakers
699752
const speakerLabels = sortedSpeakers.map(([speaker]) => speaker);
700753
const speakerData = sortedSpeakers.map(([, count]) => count);
701754

@@ -839,7 +892,7 @@ function initializeCharts() {
839892
}
840893
});
841894

842-
// Top Speakers Chart
895+
// Recent Speakers Chart
843896
const speakersCtx = document.getElementById('topSpeakersChart').getContext('2d');
844897
new Chart(speakersCtx, {
845898
type: 'bar',
@@ -855,6 +908,13 @@ function initializeCharts() {
855908
},
856909
options: {
857910
...commonOptions,
911+
plugins: {
912+
...commonOptions.plugins,
913+
title: {
914+
display: true,
915+
text: 'Recent Speakers (Last 15 Events)'
916+
}
917+
},
858918
scales: {
859919
y: {
860920
beginAtZero: true,

0 commit comments

Comments
 (0)