Skip to content

Commit d3ae06e

Browse files
silkenodwellnodwellskhairahscorner
authored
Fix event ordering and add test to confirm (#684)
* Fix event ordering and add test to confirm * Remove sorting from initial ical import as the sorting is now done in the add_upcoming_events_to_existing_events * Add comment to clarify that existing_events can include future events --------- Co-authored-by: Silke Nodwell <silke.nodwell17@imperial.ac.uk> Co-authored-by: Airah✨ <airahyusuff@gmail.com>
1 parent 888d988 commit d3ae06e

File tree

3 files changed

+80
-97
lines changed

3 files changed

+80
-97
lines changed

_data/events.yml

Lines changed: 43 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -2108,7 +2108,7 @@
21082108
- title: |
21092109
Java Bootcamp: The Grand Finale Hack Hour
21102110
description: |
2111-
The Women Coding Community (WCC) is wrapping up our Java Bootcamp with a high-energy, hands-on Hack Hour session.
2111+
The Women Coding Community (WCC) is wrapping up our Java Fullstack Bootcamp with a high-energy, hands-on Hack Hour session.
21122112
category_style: tech-talk
21132113
uid: "event_313574241@meetup.com"
21142114
category_name: Tech Talk
@@ -2129,6 +2129,26 @@
21292129
- https://docs.google.com/presentation/d/1GzJ5OlceIw-fZt6ptiQQY1OgiXxJWv_LKSTZKgBE3uQ/edit?slide=id.p1#slide=id.p1
21302130
youtube: https://www.youtube.com/watch?v=x7Fz8BvZb_Q
21312131

2132+
- title: |
2133+
Vibe Coding in London: Java, AI Agents & MCP Hands-On
2134+
description: |
2135+
The Women Coding Community (WCC) is celebrating International Women's Week with a high-energy, hands-on Vibe Coding in London.
2136+
category_style: tech-talk
2137+
uid: "event_313681243@meetup.com"
2138+
category_name: Tech Talk
2139+
date: FRI, MAR 13, 2026
2140+
expiration: "20260313"
2141+
host: ""
2142+
speaker: ""
2143+
time: 06:00 PM GMT
2144+
image:
2145+
path: "https://secure.meetupstatic.com/photos/event/7/d/6/c/600_533072108.jpeg"
2146+
alt: WCC Meetup event image
2147+
link:
2148+
path: https://www.meetup.com/women-coding-community/events/313681243/
2149+
title: View meetup event
2150+
target: _target
2151+
21322152
- title: |
21332153
Own your voice: Assertive Communication for Women in Tech
21342154
description: "We\u2019re thrilled to re-launch the Women Coding Community Career Club! We are kicking off with a powerful session led by Yasuko Ohtake, a leading technologist who will share candid insights from her career and practical strategies for visibility and influence in tech.\n"
@@ -2168,66 +2188,6 @@
21682188
title: View meetup event
21692189
target: _target
21702190

2171-
- title: |
2172-
March Book Club: AI Engineering pt 2 and Showcase
2173-
description: |
2174-
Women Coding Community Book Club! March 2026 Book: AI Engineering by Chip Huyen (continued) With a small showcase of AI engineering projects by WCC members If you would like to have a say in our next book club read, do join our channel progbookclub.
2175-
category_style: book-club
2176-
uid: "event_313316083@meetup.com"
2177-
category_name: Book Club
2178-
date: MON, MAR 30, 2026
2179-
expiration: "20260330"
2180-
host: "Silke Nodwell, Prabha Venkatesh"
2181-
speaker: ""
2182-
time: 07:00 PM BST
2183-
image:
2184-
path: "https://secure.meetupstatic.com/photos/event/7/0/d/7/600_532888887.jpeg"
2185-
alt: WCC Meetup event image
2186-
link:
2187-
path: https://www.meetup.com/women-coding-community/events/313316083/
2188-
title: View meetup event
2189-
target: _target
2190-
2191-
- title: |
2192-
From Idea to Execution: The Clarity of Building With Purpose
2193-
description: |
2194-
From Idea to Execution How to define real user problems, prioritize effectively, and lead cross-functional teams to deliver meaningful results.
2195-
category_style: tech-talk
2196-
uid: "event_313608754@meetup.com"
2197-
category_name: Tech Talk
2198-
date: WED, APR 01, 2026
2199-
expiration: "20260401"
2200-
host: ""
2201-
speaker: "Ezinne Jennifer Aruma"
2202-
time: 07:00 PM BST
2203-
image:
2204-
path: "https://secure.meetupstatic.com/photos/event/7/d/6/d/600_533072109.jpeg"
2205-
alt: WCC Meetup event image
2206-
link:
2207-
path: https://www.meetup.com/women-coding-community/events/313608754/
2208-
title: View meetup event
2209-
target: _target
2210-
2211-
- title: |
2212-
Vibe Coding in London: Java, AI Agents & MCP Hands-On
2213-
description: |
2214-
The Women Coding Community (WCC) is celebrating International Women's Week with a high-energy, hands-on Vibe Coding in London.
2215-
category_style: tech-talk
2216-
uid: "event_313681243@meetup.com"
2217-
category_name: Tech Talk
2218-
date: FRI, MAR 13, 2026
2219-
expiration: "20260313"
2220-
host: ""
2221-
speaker: ""
2222-
time: 06:00 PM GMT
2223-
image:
2224-
path: "https://secure.meetupstatic.com/photos/event/7/d/6/c/600_533072108.jpeg"
2225-
alt: WCC Meetup event image
2226-
link:
2227-
path: https://www.meetup.com/women-coding-community/events/313681243/
2228-
title: View meetup event
2229-
target: _target
2230-
22312191
- title: Design Patterns Course
22322192
description: |
22332193
Join Women Coding Community for our next session on design patterns! Design Patterns Course In this series of events, we will explore popular design patterns and their implementations in Python and Java, using "Head First Design Patterns" as our reference book.
@@ -2240,47 +2200,49 @@
22402200
speaker: ""
22412201
time: 07:00 PM GMT
22422202
image:
2243-
path: "https://secure.meetupstatic.com/photos/event/8/c/5/3/600_533195923.jpeg"
2203+
path: "https://secure.meetupstatic.com/photos/event/5/d/b/1/600_533063985.jpeg"
22442204
alt: WCC Meetup event image
22452205
link:
22462206
path: https://www.meetup.com/women-coding-community/events/313672586/
22472207
title: View meetup event
22482208
target: _target
22492209

2250-
- title: Design Patterns Course
2210+
- title: |
2211+
March Book Club: AI Engineering part 2 and Showcase
22512212
description: |
2252-
Join Women Coding Community for our next session on design patterns! Design Patterns Course In this series of events, we will explore popular design patterns and their implementations in Python and Java, using "Head First Design Patterns" as our reference book.
2253-
category_style: tech-talk
2254-
uid: "event_313778435@meetup.com"
2255-
category_name: Tech Talk
2256-
date: TUE, MAR 31, 2026
2257-
expiration: "20260331"
2258-
host: "Irina Kamalova"
2213+
Women Coding Community Book Club! March 2026 Book: AI Engineering by Chip Huyen (continued) With a small showcase of AI engineering projects by WCC members If you would like to have a say in our next book club read, do join our channel progbookclub.
2214+
category_style: book-club
2215+
uid: "event_313316083@meetup.com"
2216+
category_name: Book Club
2217+
date: MON, MAR 30, 2026
2218+
expiration: "20260330"
2219+
host: "Silke Nodwell, Prabha Venkatesh"
22592220
speaker: ""
22602221
time: 07:00 PM BST
22612222
image:
2262-
path: "https://secure.meetupstatic.com/photos/event/8/c/a/b/600_533196011.jpeg"
2223+
path: "https://secure.meetupstatic.com/photos/event/7/0/d/7/600_532888887.jpeg"
22632224
alt: WCC Meetup event image
22642225
link:
2265-
path: https://www.meetup.com/women-coding-community/events/313778435/
2226+
path: https://www.meetup.com/women-coding-community/events/313316083/
22662227
title: View meetup event
22672228
target: _target
22682229

2269-
- title: "Capacity Planning \u2013 The Math in System Design"
2230+
- title: |
2231+
From Idea to Impact: Building Products That Actually Matter
22702232
description: |
2271-
Do you want to design systems that handle real-world loads without breaking a sweat? Do you feel unsure about how mathematical principles can guide your architectural decisions? This event is designed to demystify the critical role of capacity planning in system design through real conversations with speakers who have lived experience and professional expertise.
2233+
From Idea to Impact: Building Products That Actually Matter How to define real user problems, prioritize effectively, and lead cross-functional teams to deliver meaningful results.
22722234
category_style: tech-talk
2273-
uid: "event_313858697@meetup.com"
2235+
uid: "event_313608754@meetup.com"
22742236
category_name: Tech Talk
2275-
date: SAT, APR 18, 2026
2276-
expiration: "20260418"
2277-
host: "Silke Nodwell"
2278-
speaker: "Amita Singh"
2237+
date: WED, APR 01, 2026
2238+
expiration: "20260401"
2239+
host: ""
2240+
speaker: "Ezinne Jennifer Aruma"
22792241
time: 07:00 PM BST
22802242
image:
2281-
path: "https://secure.meetupstatic.com/photos/event/6/8/5/8/600_533426712.jpeg"
2243+
path: "https://secure.meetupstatic.com/photos/event/7/d/6/d/600_533072109.jpeg"
22822244
alt: WCC Meetup event image
22832245
link:
2284-
path: https://www.meetup.com/women-coding-community/events/313858697/
2246+
path: https://www.meetup.com/women-coding-community/events/313608754/
22852247
title: View meetup event
22862248
target: _target

tools/meetup_import.py

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ class MeetupEvent(BaseModel):
6565
uid: str
6666
category_name: Optional[str] = "Tech Talk"
6767
date: str
68-
expiration: Optional[str] = ""
68+
expiration: str = ""
6969
host: Optional[str] = ""
7070
speaker: Optional[str] = ""
7171
time: Optional[str] = ""
@@ -180,12 +180,9 @@ def get_upcoming_meetups_from_ical_file(ical_path: str) -> list[MeetupEvent]:
180180
with open(ical_path, "r", encoding="utf-8") as f:
181181
calendar = Calendar(f.read())
182182

183-
# sort events to ensure order by event date
184-
sorted_events = sorted(calendar.events, key=lambda e: e.begin)
185-
186183
upcoming_meetups: list[MeetupEvent] = []
187184

188-
for event in sorted_events:
185+
for event in calendar.events:
189186
title = event.name
190187
date_obj = event.begin.datetime
191188
expiration = date_obj.strftime("%Y%m%d")
@@ -297,18 +294,31 @@ def get_event_key(event: Union[MeetupEvent, dict]) -> str:
297294
return event.uid
298295

299296
def add_upcoming_events_to_existing_events(upcoming_events: list[MeetupEvent], existing_events: list[dict]) -> list[dict]:
297+
"""Merges upcoming events with existing events, removes duplicates based on UID, and sorts by expiration date (upcoming events first)."""
298+
from datetime import datetime
299+
300+
# Merge all events by UID (upcoming overwrites existing)
300301
all_events_dict = {get_event_key(event): event for event in existing_events}
301-
added_event_count = 0
302-
logging.info("Upcoming Meetup Events:")
303302
for future_event in upcoming_events:
304303
event_key = get_event_key(future_event)
305304
all_events_dict[event_key] = future_event.model_dump()
306-
if event_key in all_events_dict:
307-
logging.info(f"{event_key} already exists in events.yml")
308-
else:
309-
added_event_count += 1
310-
logging.info(f"Added {added_event_count} new event(s) to events.yml.")
311-
return list(all_events_dict.values())
305+
306+
all_events = list(all_events_dict.values())
307+
308+
# Split into past and future events based on expiration - note that some existing_events might be in the future
309+
today = datetime.now().strftime("%Y%m%d")
310+
def is_future(event):
311+
exp = event.get("expiration", "") if isinstance(event, dict) else getattr(event, "expiration", "")
312+
return exp >= today
313+
314+
past_events = [e for e in all_events if not is_future(e)]
315+
future_events = [e for e in all_events if is_future(e)]
316+
317+
# Sort only the future events by expiration - past events will already be sorted by date
318+
future_events_sorted = sorted(future_events, key=lambda e: e.get("expiration", "") if isinstance(e, dict) else getattr(e, "expiration", ""))
319+
320+
# Concatenate past (already sorted) + sorted future
321+
return past_events + future_events_sorted
312322

313323
def write_all_events_to_yaml_file(file_path, all_events: list[dict]):
314324
try:

tools/tests/meetup_import_test.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,13 +127,13 @@ def test_add_upcoming_events_to_existing_events_removes_duplicates_even_with_cha
127127

128128
def test_get_added_events_with_empty_existing():
129129
existing = []
130-
upcoming = [MeetupEvent(title='Talk', date='JAN 1, 2025', uid='event-1', description='')]
130+
upcoming = [MeetupEvent(title='Talk', date='JAN 1, 2025', expiration='20250101', uid='event-1', description='')]
131131
all_events = add_upcoming_events_to_existing_events(upcoming, existing)
132132
assert len(all_events) == 1
133133
assert all_events[0]['uid'] == 'event-1'
134134

135135
def test_get_added_events_with_empty_upcoming():
136-
existing = [{'title': 'Talk', 'date': 'JAN 1, 2025', 'uid': 'event-1', 'description': ''}]
136+
existing = [{'title': 'Talk', 'date': 'JAN 1, 2025', 'expiration': '20250101', 'uid': 'event-1', 'description': ''}]
137137
upcoming = []
138138
all_events = add_upcoming_events_to_existing_events(upcoming, existing)
139139
assert len(all_events) == 1
@@ -167,4 +167,15 @@ def test_process_meetup_data_fields():
167167
assert isinstance(result['title'], (LiteralString, str))
168168
assert isinstance(result['expiration'], QuotedString)
169169
assert isinstance(result['image']['path'], (QuotedString, NoQuoteString))
170-
assert isinstance(result['link']['title'], (QuotedString, NoQuoteString))
170+
assert isinstance(result['link']['title'], (QuotedString, NoQuoteString))
171+
172+
def test_events_are_sorted_by_date_after_adding_upcoming():
173+
existing = [
174+
{'title': 'Event A', 'date': 'APR 1, 2026', 'expiration': '20260401', 'uid': 'event-a', 'description': ''},
175+
]
176+
upcoming = [
177+
MeetupEvent(title='Event B', date='MAR 13, 2025', expiration='20250313', uid='event-b', description='')
178+
]
179+
all_events = add_upcoming_events_to_existing_events(upcoming, existing)
180+
assert len(all_events) == 2
181+
assert all_events[0]['uid'] == 'event-b' # Event B is earlier than Event A

0 commit comments

Comments
 (0)