From 31ea65c777a54810a98a4068cc0e6d4e0db955f3 Mon Sep 17 00:00:00 2001 From: Airah Yusuff Date: Tue, 30 Sep 2025 18:55:05 +0100 Subject: [PATCH] update sort only after hours have been updated to the new data --- tools/automation_prepare_adhoc_availability.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tools/automation_prepare_adhoc_availability.py b/tools/automation_prepare_adhoc_availability.py index b565db3b..f2a5c2b7 100644 --- a/tools/automation_prepare_adhoc_availability.py +++ b/tools/automation_prepare_adhoc_availability.py @@ -103,10 +103,7 @@ def update_mentor_availability(month, xlsx_file_path, yml_file_path): mentor['availability'] = [] continue - # otherwise: mentor is available, update sort and reset availability to the current month only - current_availability = mentor.get('availability', []) - mentor['sort'] = get_available_mentor_sort(mentor, current_availability) - mentor['availability'] = [month] + # otherwise: mentor is available # Only update hours if updated hours is not None updated_hours = availability_updates.get(yml_name) @@ -114,6 +111,11 @@ def update_mentor_availability(month, xlsx_file_path, yml_file_path): logging.info(f"Updating hours for {yml_name} to: {updated_hours}") mentor['hours'] = updated_hours + # update sort and reset availability to the current month only + current_availability = mentor.get('availability', []) + mentor['sort'] = get_available_mentor_sort(mentor, current_availability) + mentor['availability'] = [month] + with open(yml_file_path, 'w') as f: yaml.default_flow_style = True yaml.dump(mentors, f)