Skip to content

Commit 08e596f

Browse files
committed
Rebase
1 parent b596b99 commit 08e596f

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

bot/code_review_bot/backend.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -190,19 +190,29 @@ def list_diff_issues(self, diff_id):
190190

191191
def list_diff_issues_v2(self, diff_id, mode):
192192
"""
193-
List issues for a given dif
193+
List issues for a given diff, applying specific filters.
194+
Returns:
195+
* The ID of the previous diff if it exists (always null for `known` mode).
196+
* A list of issues (dict serializing ID and hash) corresponding to the filter.
194197
"""
195198
assert mode in ("known", "unresolved", "closed")
196199
try:
197-
return list(self.paginate(f"/v2/diff/{diff_id}/issues/{mode}"))
200+
data = self.get(f"/v2/diff/{diff_id}/issues/{mode}")
198201
except HTTPError as e:
199202
if e.response.status_code != 404:
200203
logger.warning(
201-
f"Cound not list {mode} issues from the bot: {e}. Skipping"
204+
f"Could not list {mode} issues from the bot: {e}. Skipping"
202205
)
203206
else:
204207
logger.info(f"Diff not found in code review backend: {diff_id}")
205-
return []
208+
return None, []
209+
return data["previous_diff_id"], data["issues"]
210+
211+
def get(self, url):
212+
auth = (self.username, self.password)
213+
resp = requests.get(url, auth=auth, headers=GetAppUserAgent())
214+
resp.raise_for_status()
215+
return resp.json()
206216

207217
def paginate(self, url_path):
208218
"""

0 commit comments

Comments
 (0)