11import sys
22import time
3- from typing import List
3+ from typing import List , OrderedDict
44
55import schedule as sched
66
99from mapswipe_workers .utils .slack_helper import send_slack_message
1010
1111
12- def get_projects (status : str ) -> dict :
12+ def get_projects (status : str ) -> OrderedDict :
1313 """Load 'active' projects from Firebase."""
1414 fb_db = firebaseDB ()
1515 projects = (
@@ -20,7 +20,7 @@ def get_projects(status: str) -> dict:
2020
2121
2222def filter_projects_by_name_and_progress (
23- projects : dict , filter_string : str , progress_threshold : int
23+ projects : OrderedDict , filter_string : str , progress_threshold : int
2424) -> List [str ]:
2525 """Filter projects by name (lowercase) and progress."""
2626 selected_project_ids = []
@@ -62,6 +62,12 @@ def run_update_project_status(filter_string: str) -> None:
6262 )
6363
6464 inactive_projects = get_projects (status = "inactive" )
65+ # We sort projects by their attribute "projectNumber" to ensure that
66+ # always the lowest one will be set to "status=active" next.
67+ inactive_projects = OrderedDict (
68+ sorted (inactive_projects .items (), key = lambda x : x [1 ]["projectNumber" ])
69+ )
70+
6571 new_active_projects = filter_projects_by_name_and_progress (
6672 inactive_projects , filter_string , progress_threshold = 0 ,
6773 )[0 : len (finished_projects )]
0 commit comments