{{ item.processed_status }}
+ {{ item.count }}
+ diff --git a/app/main.py b/app/main.py index 034b80f..5d6da41 100644 --- a/app/main.py +++ b/app/main.py @@ -111,6 +111,15 @@ DEFAULT_ATTEMPT_TTL_SECONDS = 24 * 60 * 60 MIN_ATTEMPT_TTL_SECONDS = 60 MAX_ATTEMPT_TTL_SECONDS = 7 * 24 * 60 * 60 +WEBHOOK_OUTCOME_SCAN_ORDER = { + "missing_submitter": 0, + "bounty_not_found": 1, + "exhausted_bounty": 2, + "duplicate_delivery": 3, + "delivery_payload_mismatch": 4, + "already_paid": 5, + "paid": 6, +} def _request_was_forwarded_https(request: Request) -> bool: @@ -247,6 +256,27 @@ def _existing_payout_proof_for_submission( ) +def webhook_status_summary(session: Session) -> list[dict[str, Any]]: + status_expr = func.lower(WebhookEvent.processed_status) + count_expr = func.count(WebhookEvent.delivery_id) + rows = session.execute( + select(status_expr, count_expr) + .group_by(status_expr) + .order_by(count_expr.desc(), status_expr.asc()) + ).all() + summary = [ + {"processed_status": str(status), "count": int(count)} for status, count in rows if status + ] + return sorted( + summary, + key=lambda item: ( + WEBHOOK_OUTCOME_SCAN_ORDER.get(str(item["processed_status"]), 100), + -int(item["count"]), + str(item["processed_status"]), + ), + ) + + def _host_without_port(request: Request) -> str: return request.headers.get("host", "").split(":", 1)[0].lower() @@ -1432,6 +1462,7 @@ def admin_page( WebhookEvent.created_at.desc(), WebhookEvent.delivery_id.desc() ).limit(webhook_limit) ).all() + webhook_summary = webhook_status_summary(session) return templates.TemplateResponse( request, "admin.html", @@ -1439,6 +1470,7 @@ def admin_page( "login": login, "csrf_token": _csrf_token("admin-bounty", login, settings.cookie_secret), "webhook_events": webhook_events, + "webhook_status_summary": webhook_summary, "webhook_limit": webhook_limit, "webhook_limit_options": [10, 25, 50, 100], "webhook_status": normalized_status, diff --git a/app/templates/admin.html b/app/templates/admin.html index 9d22023..a02e89f 100644 --- a/app/templates/admin.html +++ b/app/templates/admin.html @@ -21,6 +21,16 @@
Webhooks
{{ item.processed_status }}
+ {{ item.count }}
+