11import sys
22import time
3+ from typing import List
34
45import schedule as sched
56
89from mapswipe_workers .utils .slack_helper import send_slack_message
910
1011
11- def get_projects (status ) :
12+ def get_projects (status : str ) -> dict :
1213 """Load 'active' projects from Firebase."""
1314 fb_db = firebaseDB ()
1415 projects = (
@@ -18,7 +19,9 @@ def get_projects(status):
1819 return projects
1920
2021
21- def filter_projects_by_name_and_progress (projects , filter_string , progress_threshold ):
22+ def filter_projects_by_name_and_progress (
23+ projects : dict , filter_string : str , progress_threshold : int
24+ ) -> List [str ]:
2225 """Filter projects by name (lowercase) and progress."""
2326 selected_project_ids = []
2427 for project_id in projects .keys ():
@@ -34,7 +37,7 @@ def filter_projects_by_name_and_progress(projects, filter_string, progress_thres
3437 return selected_project_ids
3538
3639
37- def set_status_in_firebase (project_id , project_name , new_status ) :
40+ def set_status_in_firebase (project_id : str , project_name : str , new_status : str ) -> None :
3841 """Change status of a project in Firebase."""
3942 # change status in firebase
4043 fb_db = firebaseDB ()
@@ -50,7 +53,7 @@ def set_status_in_firebase(project_id, project_name, new_status):
5053 send_slack_message (MessageType .PROJECT_STATUS_ACTIVE , project_name , project_id )
5154
5255
53- def run_update_project_status (filter_string ) :
56+ def run_update_project_status (filter_string : str ) -> None :
5457 """Run the workflow to update project status for all filtered projects."""
5558 logger .info ("### Start update project status workflow ###" )
5659 active_projects = get_projects (status = "active" )
@@ -80,6 +83,14 @@ def run_update_project_status(filter_string):
8083if __name__ == "__main__" :
8184 """Use this command to run in docker container.
8285 docker-compose run -d mapswipe_workers_creation python3 python_scripts/update_project_status.py "test" 30 # noqa
86+
87+ You can two arguments to the script
88+ - filter string, e.g. "test"
89+ - time interval in minutes, e.g. 30
90+
91+ Make sure that you don't run this script too frequently as it pulls data from firebase and
92+ this will have implications on costs. Running this script once every 15-30 minutes should be totally fine.
93+ This means that there can be a "delay" in setting a project to finished about roughly the same time.
8394 """
8495 try :
8596 filter_string = sys .argv [1 ]
0 commit comments