@@ -852,25 +852,32 @@ def validate_emails(self):
852852 def execute (self ):
853853 if self .is_valid ():
854854 team_users = set ()
855+ role_email_map = defaultdict (list )
856+
857+ user_to_retrieve = []
858+ for contributor in self ._contributors :
859+ role_email_map [contributor .role ].append (contributor .email )
860+ user_to_retrieve .append (contributor .email )
861+
862+ users = self ._service_provider .work_management .list_users (
863+ Filter ("role" , constants .UserRole .CONTRIBUTOR .value , OperatorEnum .EQ )
864+ & Filter ("email" , user_to_retrieve , OperatorEnum .IN ),
865+ parent_entity = CustomFieldEntityEnum .TEAM ,
866+ ).data
867+ for user in users :
868+ team_users .add (user .email )
869+
870+ to_skip = []
871+ to_add = []
872+
855873 project_users = self ._service_provider .work_management .list_users (
856- EmptyQuery ( ),
874+ Filter ( "email" , user_to_retrieve , OperatorEnum . IN ),
857875 include_custom_fields = True ,
858876 parent_entity = CustomFieldEntityEnum .PROJECT ,
859877 project_id = self ._project .id ,
860878 ).data
861879 project_emails = {user .email for user in project_users }
862- users = self ._service_provider .work_management .list_users (
863- EmptyQuery (), parent_entity = CustomFieldEntityEnum .TEAM
864- ).data
865- for user in users :
866- if user .role == constants .UserRole .CONTRIBUTOR .value :
867- team_users .add (user .email )
868880
869- role_email_map = defaultdict (list )
870- to_skip = []
871- to_add = []
872- for contributor in self ._contributors :
873- role_email_map [contributor .role ].append (contributor .email )
874881 for role_id , emails in role_email_map .items ():
875882 role_name = self ._service_provider .get_role_name (self ._project , role_id )
876883 _to_add = list (team_users .intersection (emails ) - project_emails )
@@ -925,7 +932,8 @@ def __init__(
925932 def execute (self ):
926933 if self .is_valid ():
927934 all_users = self ._service_provider .work_management .list_users (
928- EmptyQuery (), parent_entity = CustomFieldEntityEnum .TEAM
935+ Filter ("email" , self ._emails , OperatorEnum .IN ),
936+ parent_entity = CustomFieldEntityEnum .TEAM ,
929937 ).data
930938 # collecting pending team users
931939 team_user_emails = []
0 commit comments