Skip to content

Commit be7bc80

Browse files
committed
Show recent PR activity in hours
1 parent 9aa1fe5 commit be7bc80

1 file changed

Lines changed: 17 additions & 2 deletions

File tree

.github/scripts/pull-request-dashboard.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,21 @@ def days_since(ts: datetime | None) -> int | None:
280280
return max(0, (datetime.now(timezone.utc) - ts).days)
281281

282282

283+
def activity_age(ts: datetime | None) -> str:
284+
if ts is None:
285+
return "?"
286+
seconds = max(0, int((datetime.now(timezone.utc) - ts).total_seconds()))
287+
minutes = seconds // 60
288+
if minutes < 1:
289+
return "<1m"
290+
if minutes < 60:
291+
return f"{minutes}m"
292+
hours = minutes // 60
293+
if hours < 24:
294+
return f"{hours}h"
295+
return f"{hours // 24}d"
296+
297+
283298
def truncate(s: str, n: int = MAX_BODY_CHARS) -> str:
284299
s = (s or "").strip()
285300
if len(s) <= n:
@@ -482,6 +497,7 @@ def compute_facts(raw: dict[str, Any], author: str) -> dict[str, Any]:
482497
"ci_pending_count": len(pending),
483498
"conflicts": compute_conflicts(pr),
484499
"days_since_last_activity": days_since(last_activity_ts),
500+
"last_activity_age": activity_age(last_activity_ts),
485501
}
486502

487503

@@ -942,8 +958,7 @@ def render_markdown_compact(
942958
res = results.get(number) or {}
943959
facts = res.get("facts") or {}
944960
author = facts.get("author") or actor_login(pr.get("author") or {})
945-
activity = facts.get("days_since_last_activity")
946-
activity_cell = "?" if activity is None else f"{activity}d"
961+
activity_cell = facts.get("last_activity_age") or "?"
947962
out.append(
948963
f"| [{title}]({url}) | {author} | {ci_cell(facts)} | "
949964
f"{conflicts_cell(facts)} | {activity_cell} |"

0 commit comments

Comments
 (0)