@@ -115,17 +115,20 @@ def collect(self, repo_git, key_auth, since):
115115 owner , repo = get_owner_repo (repo_git )
116116 self .repo_identifier = f"{ owner } /{ repo } "
117117
118+ # Build mappings once before processing any events
119+ issue_url_to_id_map = self ._get_map_from_issue_url_to_id (repo_id )
120+ pr_url_to_id_map = self ._get_map_from_pr_url_to_id (repo_id )
121+
118122 events = []
119123 for event in self ._collect_events (repo_git , key_auth , since ):
120124 events .append (event )
121125
122- # making this a decent size since process_events retrieves all the issues and prs each time
123126 if len (events ) >= 500 :
124- self ._process_events (events , repo_id )
127+ self ._process_events (events , repo_id , issue_url_to_id_map , pr_url_to_id_map )
125128 events .clear ()
126129
127130 if events :
128- self ._process_events (events , repo_id )
131+ self ._process_events (events , repo_id , issue_url_to_id_map , pr_url_to_id_map )
129132
130133 def _collect_events (self , repo_git : str , key_auth , since ):
131134
@@ -143,7 +146,7 @@ def _collect_events(self, repo_git: str, key_auth, since):
143146 if since and datetime .fromisoformat (event ["created_at" ].replace ("Z" , "+00:00" )).replace (tzinfo = timezone .utc ) < since :
144147 return
145148
146- def _process_events (self , events , repo_id ):
149+ def _process_events (self , events , repo_id , issue_url_to_id_map , pr_url_to_id_map ):
147150
148151 issue_events = []
149152 pr_events = []
@@ -161,19 +164,16 @@ def _process_events(self, events, repo_id):
161164 if not_mappable_events :
162165 self ._logger .warning (f"{ self .repo_identifier } - { self .task_name } : Unable to map these github events to an issue or pr: { not_mappable_events } " )
163166
164- self ._process_issue_events (issue_events , repo_id )
165- self ._process_pr_events (pr_events , repo_id )
167+ self ._process_issue_events (issue_events , repo_id , issue_url_to_id_map )
168+ self ._process_pr_events (pr_events , repo_id , pr_url_to_id_map )
166169
167170 update_issue_closed_cntrbs_by_repo_id (repo_id )
168171
169- def _process_issue_events (self , issue_events , repo_id ):
172+ def _process_issue_events (self , issue_events , repo_id , issue_url_to_id_map ):
170173
171174 issue_event_dicts = []
172175 contributors = []
173176
174-
175- issue_url_to_id_map = self ._get_map_from_issue_url_to_id (repo_id )
176-
177177 for event in issue_events :
178178
179179 event , contributor = self ._process_github_event_contributors (event )
@@ -200,13 +200,11 @@ def _process_issue_events(self, issue_events, repo_id):
200200
201201 self ._insert_issue_events (issue_event_dicts )
202202
203- def _process_pr_events (self , pr_events , repo_id ):
203+ def _process_pr_events (self , pr_events , repo_id , pr_url_to_id_map ):
204204
205205 pr_event_dicts = []
206206 contributors = []
207207
208- pr_url_to_id_map = self ._get_map_from_pr_url_to_id (repo_id )
209-
210208 for event in pr_events :
211209
212210 event , contributor = self ._process_github_event_contributors (event )
0 commit comments