@@ -325,6 +325,7 @@ def send_user_reports_mail_org(
325325 start_date = None ,
326326 end_date = None ,
327327 period = None ,
328+ workspace_ids = None ,
328329):
329330 """Function to generate CSV of organization user reports and send mail to the owner/admin
330331
@@ -340,8 +341,13 @@ def send_user_reports_mail_org(
340341
341342 user = User .objects .get (id = user_id )
342343 organization = Organization .objects .get (pk = org_id )
344+
345+ if not workspace_ids :
346+ print ("❌ No workspace IDs provided, exiting task" )
347+ return
348+
343349 proj_objs = Project .objects .filter (
344- organization_id = org_id , project_type = project_type
350+ organization_id = org_id , project_type = project_type , workspace_id__in = workspace_ids ,
345351 )
346352
347353 if period :
@@ -825,6 +831,7 @@ def send_project_analytics_mail_org(
825831 user_id ,
826832 sort_by_column_name ,
827833 descending_order ,
834+ workspace_ids
828835):
829836 organization = Organization .objects .get (pk = org_id )
830837 user = User .objects .get (id = user_id )
@@ -834,18 +841,22 @@ def send_project_analytics_mail_org(
834841
835842 if descending_order == None :
836843 descending_order = False
837-
844+
845+ if not workspace_ids :
846+ print ("❌ No workspace IDs provided, exiting task" )
847+ return
848+
838849 if tgt_language == None :
839850 selected_language = "-"
840851 projects_obj = Project .objects .filter (
841- organization_id = org_id , project_type = project_type
852+ organization_id = org_id , project_type = project_type , workspace_id__in = workspace_ids
842853 )
843854 else :
844855 selected_language = tgt_language
845856 projects_obj = Project .objects .filter (
846857 organization_id = org_id ,
847858 tgt_language = tgt_language ,
848- project_type = project_type ,
859+ project_type = project_type ,workspace_id__in = workspace_ids
849860 )
850861 final_result = []
851862 if projects_obj .count () != 0 :
0 commit comments