From 52c5cc1af1d7b8b3f1537642d69b6031e034c149 Mon Sep 17 00:00:00 2001 From: Anton Date: Thu, 7 May 2026 16:23:39 +0300 Subject: [PATCH] fix: make run rows clickable and limit dashboard runs --- app/admin.py | 2 +- app/static/admin.js | 4 ++++ app/templates/dashboard.html | 2 +- app/version.py | 6 +++--- tests/test_admin_templates.py | 14 ++++++++++++++ tests/test_api_mcp.py | 2 +- 6 files changed, 24 insertions(+), 6 deletions(-) diff --git a/app/admin.py b/app/admin.py index 0348ff4..d0c8465 100644 --- a/app/admin.py +++ b/app/admin.py @@ -29,7 +29,7 @@ def dashboard(request: Request, db: Session = Depends(get_db), settings: Setting counts = stats_payload(db) counts["runs"] = db.scalar(select(func.count()).select_from(CrawlRun)) or 0 counts["errors"] = db.scalar(select(func.count()).select_from(CrawlError)) or 0 - run_models = db.scalars(select(CrawlRun).order_by(desc(CrawlRun.started_at)).limit(10)).all() + run_models = db.scalars(select(CrawlRun).order_by(desc(CrawlRun.started_at)).limit(5)).all() runs = [run_payload(run) for run in run_models] return _render(request, "dashboard.html", {"counts": counts, "runs": runs, "latest_run": runs[0] if runs else None}) diff --git a/app/static/admin.js b/app/static/admin.js index 54ebf9c..fbf7d2d 100644 --- a/app/static/admin.js +++ b/app/static/admin.js @@ -59,6 +59,9 @@ applyColumns(columns); }); }); + } + + function setupClickableRows() { document.querySelectorAll("[data-row-href]").forEach((row) => { row.addEventListener("click", (event) => { if (event.target.closest("a, button, input, select, label")) return; @@ -107,5 +110,6 @@ } setupColumns(); + setupClickableRows(); setupProgress(); })(); diff --git a/app/templates/dashboard.html b/app/templates/dashboard.html index 016e451..f0d9db0 100644 --- a/app/templates/dashboard.html +++ b/app/templates/dashboard.html @@ -51,7 +51,7 @@ IDСтатусОбработаноОшибкиСтарт {% for run in runs %} - {{ run.id }}{{ run.status_display }}{{ run.parsed_count }}{{ run.error_count }}{{ run.started_display }} + {{ run.id }}{{ run.status_display }}{{ run.parsed_count }}{{ run.error_count }}{{ run.started_display }} {% endfor %} diff --git a/app/version.py b/app/version.py index 5ab7401..02069bb 100644 --- a/app/version.py +++ b/app/version.py @@ -1,3 +1,3 @@ -APP_VERSION = "0.4.1" -FRONTEND_VERSION = "0.4.1" -BACKEND_VERSION = "0.4.1" +APP_VERSION = "0.4.2" +FRONTEND_VERSION = "0.4.2" +BACKEND_VERSION = "0.4.2" diff --git a/tests/test_admin_templates.py b/tests/test_admin_templates.py index 106447f..b7250db 100644 --- a/tests/test_admin_templates.py +++ b/tests/test_admin_templates.py @@ -35,6 +35,13 @@ def test_admin_employees_route_redirects_to_directory(): assert 'RedirectResponse("/admin/directory", status_code=303)' in source +def test_dashboard_limits_latest_runs_to_five(): + source = Path("app/admin.py").read_text(encoding="utf-8") + + assert "order_by(desc(CrawlRun.started_at)).limit(5)" in source + assert "order_by(desc(CrawlRun.started_at)).limit(10)" not in source + + def test_runs_template_links_to_run_detail(): template = Path("app/templates/runs.html").read_text(encoding="utf-8") @@ -61,3 +68,10 @@ def test_dashboard_metric_cards_link_to_admin_targets(): assert '/admin/runs/{{ latest_run.id }}#new-employees' in template assert 'href="/admin/directory?status=dismissed"' in template assert 'href="/admin/runs"' in template + + +def test_dashboard_latest_run_rows_link_to_run_detail(): + template = Path("app/templates/dashboard.html").read_text(encoding="utf-8") + + assert 'data-row-href="/admin/runs/{{ run.id }}"' in template + assert 'href="/admin/runs/{{ run.id }}"' in template diff --git a/tests/test_api_mcp.py b/tests/test_api_mcp.py index e753931..24fcea2 100644 --- a/tests/test_api_mcp.py +++ b/tests/test_api_mcp.py @@ -23,7 +23,7 @@ def test_health_returns_versions(): response = client.get("/api/health") assert response.status_code == 200 - assert response.json()["backend_version"] == "0.4.1" + assert response.json()["backend_version"] == "0.4.2" def test_mcp_requires_token_and_lists_tools(): -- 2.49.1