@@ -18,32 +18,32 @@ def send_slack_message(message_type: str, project_name: str, project_id: str = N
1818 if message_type == "success" :
1919 message = (
2020 "### PROJECT CREATION SUCCESSFUL ###\n "
21- + "Project Name: {0 }\n " . format ( project_name )
22- + "Project Id: {0 }\n \n " . format ( project_id )
21+ + f "Project Name: { project_name } \n "
22+ + f "Project Id: { project_id } \n \n "
2323 + "Make sure to activate the project using the manager dashboard.\n "
2424 + "Happy Swiping. :)"
2525 )
2626 slack_client .chat_postMessage (channel = SLACK_CHANNEL , text = message )
2727 elif message_type == "fail" :
2828 message = (
2929 "### PROJECT CREATION FAILED ###\n "
30- + "Project Name: {0 }\n " . format ( project_name )
30+ + f "Project Name: { project_name } \n "
3131 + "Project draft is deleted."
3232 )
3333 slack_client .chat_postMessage (channel = SLACK_CHANNEL , text = message )
3434 elif message_type == "notification_90" :
3535 message = (
3636 "### ALMOST THERE! PROJECT REACHED 90% ###\n "
37- + "Project Name: {0 }\n " . format ( project_name )
38- + "Project Id: {0 }\n \n " . format ( project_id )
37+ + f "Project Name: { project_name } \n "
38+ + f "Project Id: { project_id } \n \n "
3939 + "Get your next projects ready."
4040 )
4141 slack_client .chat_postMessage (channel = "mapswipe_managers" , text = message )
4242 elif message_type == "notification_100" :
4343 message = (
4444 "### GREAT! PROJECT REACHED 100% ###\n "
45- + "Project Name: {0 }\n " . format ( project_name )
46- + "Project Id: {0 }\n \n " . format ( project_id )
45+ + f "Project Name: { project_name } \n "
46+ + f "Project Id: { project_id } \n \n "
4747 + "You can set this project to 'finished' "
4848 + "and activate another one."
4949 )
@@ -57,24 +57,26 @@ def send_progress_notification(project_id: int):
5757 """Send progress notification to project managers in Slack."""
5858 fb_db = auth .firebaseDB ()
5959 progress = fb_db .reference (f"v2/projects/{ project_id } /progress" ).get ()
60- project_name = fb_db .reference (f"v2/projects/{ project_id } /name" ).get ()
61- notification_90_sent = fb_db .reference (
62- f"v2/projects/{ project_id } /notification_90_sent"
63- ).get ()
64- notification_100_sent = fb_db .reference (
65- f"v2/projects/{ project_id } /notification_100_sent"
66- ).get ()
67- logger .info (
68- f"{ project_id } - progress: { progress } ,"
69- f"notifications: { notification_90_sent } { notification_100_sent } "
70- )
7160
72- if progress >= 90 and not notification_90_sent :
73- # send notification and set value in firebase
74- fb_db .reference (f"v2/projects/{ project_id } /notification_90_sent" ).set (True )
75- send_slack_message ("notification_90" , project_name , project_id )
61+ if progress >= 90 :
62+ project_name = fb_db .reference (f"v2/projects/{ project_id } /name" ).get ()
63+ notification_90_sent = fb_db .reference (
64+ f"v2/projects/{ project_id } /notification_90_sent"
65+ ).get ()
66+ notification_100_sent = fb_db .reference (
67+ f"v2/projects/{ project_id } /notification_100_sent"
68+ ).get ()
69+ logger .info (
70+ f"{ project_id } - progress: { progress } ,"
71+ f"notifications: { notification_90_sent } { notification_100_sent } "
72+ )
73+
74+ if progress >= 90 and not notification_90_sent :
75+ # send notification and set value in firebase
76+ send_slack_message ("notification_90" , project_name , project_id )
77+ fb_db .reference (f"v2/projects/{ project_id } /notification_90_sent" ).set (True )
7678
77- if progress >= 100 and not notification_100_sent :
78- # send notification and set value in firebase
79- fb_db . reference ( f"v2/projects/ { project_id } /notification_100_sent" ). set ( True )
80- send_slack_message ( "notification_100" , project_name , project_id )
79+ if progress >= 100 and not notification_100_sent :
80+ # send notification and set value in firebase
81+ send_slack_message ( "notification_100" , project_name , project_id )
82+ fb_db . reference ( f"v2/projects/ { project_id } /notification_100_sent" ). set ( True )
0 commit comments