@@ -131,44 +131,54 @@ async def dmp_updates():
131131 str (issue_response .status_code ) + " for dmp_id: " + str (dmp_id ))
132132
133133 # 2. Read & Update comments of the ticket
134- GITHUB_COMMENTS_URL = "https://api.github.com/repos/{owner}/{repo}/issues/{issue_number}/comments"
135- comments_url = GITHUB_COMMENTS_URL .format (
136- owner = owner , repo = repo , issue_number = issue_number )
137- async with httpx .AsyncClient () as client :
138- comments_response = await client .get (comments_url , headers = headers )
139- if comments_response .status_code == 200 :
140- week_update_status = False
141- # Loop through comments
142- for val in comments_response .json ():
143- # Handle if any of the comments are week data
144- plain_text_body = markdown2 .markdown (val ['body' ])
145- if "Weekly Goals" in plain_text_body and not week_update_status :
146- week_update_status = handle_week_data (val , dmp ['issue_url' ], dmp_id , issue_update ['mentor_username' ])
147-
148- # Parse comments
149- comment_update = define_issue_update (
150- val , dmp_id = dmp_id )
151- app .logger .info (
152- 'Comment from remote: ' , comment_update )
153- upsert_comments = db .upsert_data (
154- comment_update , 'dmp_issue_updates' )
155- app .logger .info (upsert_comments )
156- else :
157- app .logger .error ("Comments API failed: " +
158- str (issue_response .status_code ) + " for dmp_id: " + str (dmp_id ))
134+ page = 1
135+ while True :
136+ GITHUB_COMMENTS_URL = "https://api.github.com/repos/{owner}/{repo}/issues/{issue_number}/comments?page={page}"
137+ comments_url = GITHUB_COMMENTS_URL .format (
138+ owner = owner , repo = repo , issue_number = issue_number , page = page )
139+ async with httpx .AsyncClient () as client :
140+ comments_response = await client .get (comments_url , headers = headers )
141+ if comments_response .status_code == 200 :
142+ week_update_status = False
143+ week_learning_status = False
144+ # Loop through comments
145+ comments_array = comments_response .json ()
146+ if comments_array == [] or len (comments_array )== 0 :
147+ break
148+ for val in comments_response .json ():
149+ # Handle if any of the comments are week data
150+ plain_text_body = markdown2 .markdown (val ['body' ])
151+ if "Weekly Goals" in plain_text_body and not week_update_status :
152+ week_update_status = handle_week_data (val , dmp ['issue_url' ], dmp_id , issue_update ['mentor_username' ])
153+
154+ if "Weekly Learnings" in plain_text_body and not week_learning_status :
155+ week_learning_status = handle_week_data (val , dmp ['issue_url' ], dmp_id , issue_update ['mentor_username' ])
156+
157+ # Parse comments
158+ comment_update = define_issue_update (
159+ val , dmp_id = dmp_id )
160+ app .logger .info (
161+ 'Comment from remote: ' , comment_update )
162+ upsert_comments = db .upsert_data (
163+ comment_update , 'dmp_issue_updates' )
164+ app .logger .info (upsert_comments )
165+ else :
166+ app .logger .error ("Comments API failed: " +
167+ str (issue_response .status_code ) + " for dmp_id: " + str (dmp_id ))
168+ page = page + 1
159169
160170 # 3. Read & Update PRs of the ticket
161- GITHUB_PR_URL = "https://api.github.com/repos/{owner}/{repo}/pulls"
171+ GITHUB_PR_URL = "https://api.github.com/repos/{owner}/{repo}/pulls?state=all "
162172 pr_url = GITHUB_PR_URL .format (owner = owner , repo = repo )
163173 async with httpx .AsyncClient () as client :
164174 pr_response = await client .get (pr_url , headers = headers )
165175 if pr_response .status_code == 200 :
166176 for pr_val in pr_response .json ():
167177 # Select only those prs which have the issue number in ticket
168- if "#" + str (issue_number ) not in pr_val ['title' ]:
178+ if str (issue_number ) not in pr_val ['title' ]:
169179 continue
170180 pr_created_at = pr_val ['created_at' ]
171- if (pr_created_at >= TARGET_DATE ) or 1 == 1 :
181+ if (pr_created_at >= TARGET_DATE ):
172182 pr_data = define_pr_update (pr_val , dmp_id )
173183 upsert_pr = db .upsert_data (
174184 pr_data , 'dmp_pr_updates' )
0 commit comments