Skip to content

Commit ba06a8c

Browse files
committed
circuitpython_libraries.py: add oldest/newest info for open library PRs; wrap core download stats api request in a try (getting errors in the request)
1 parent 92f0c8e commit ba06a8c

File tree

1 file changed

+21
-4
lines changed

1 file changed

+21
-4
lines changed

adabot/circuitpython_libraries.py

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -215,16 +215,26 @@ def run_library_checks(validators, bundle_submodules, latest_pylint, kw_args):
215215
output_handler()
216216
output_handler("Libraries")
217217
print_pr_overview(lib_insights)
218-
output_handler("* Merged pull requests:".format(len(lib_insights["open_prs"])))
218+
output_handler(" * Merged pull requests:")
219219
sorted_prs = sorted(lib_insights["merged_prs"],
220220
key=lambda days: int(close_pr_sort_re.search(days).group(1)),
221221
reverse=True)
222222
for pr in sorted_prs:
223-
output_handler(" * {}".format(pr))
223+
output_handler(" * {}".format(pr))
224224
print_issue_overview(lib_insights)
225225
output_handler("* https://circuitpython.org/contributing")
226226
output_handler(" * {} open issues".format(len(lib_insights["open_issues"])))
227-
output_handler(" * {} open pull requests".format(len(lib_insights["open_prs"])))
227+
open_pr_days = [
228+
int(pr_sort_re.search(pr).group(1)) for pr in lib_insights["open_prs"]
229+
if pr_sort_re.search(pr) is not None
230+
]
231+
output_handler(
232+
" * {0} open pull requests (Oldest: {1}, Newest: {2})".format(
233+
len(lib_insights["open_prs"]),
234+
max(open_pr_days),
235+
max((min(open_pr_days), 1)) # ensure the minumum is '1'
236+
)
237+
)
228238
output_handler("Library updates in the last seven days:")
229239
if len(new_libs) != 0:
230240
output_handler("**New Libraries**")
@@ -283,7 +293,14 @@ def output_handler(message="", quiet=False):
283293

284294
def print_circuitpython_download_stats():
285295
"""Gather and report analytics on the main CircuitPython repository."""
286-
response = github.get("/repos/adafruit/circuitpython/releases")
296+
try:
297+
response = github.get("/repos/adafruit/circuitpython/releases")
298+
except (ValueError, RuntimeError):
299+
output_handler(
300+
"Core CircuitPython GitHub download statistics request failed."
301+
)
302+
return
303+
287304
if not response.ok:
288305
output_handler(
289306
"Core CircuitPython GitHub download statistics request failed."

0 commit comments

Comments
 (0)