From 451f74bc1ca6027bb5ba4d372c6cf0c4d5888eea Mon Sep 17 00:00:00 2001 From: "Jens W. Klein" Date: Wed, 1 Jul 2026 08:00:14 +0200 Subject: [PATCH] fix(zmi): show configured slow-query threshold in empty state The Slow Queries tab's 'no slow queries yet' message hard-coded the PGCATALOG_SLOW_QUERY_MS env var name and its default of 10ms. The actual configured value is more useful, and manage_get_slow_query_threshold() (already used for the header) exposes it. Show that instead. Co-Authored-By: Claude Opus 4.8 (1M context) --- CHANGES.md | 8 ++++++ .../pgcatalog/www/catalogSlowQueries.dtml | 5 ++-- tests/test_slow_queries_view.py | 27 +++++++++++++++++++ 3 files changed, 38 insertions(+), 2 deletions(-) create mode 100644 tests/test_slow_queries_view.py diff --git a/CHANGES.md b/CHANGES.md index 86d113c..a6d1cb2 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,13 @@ # Changelog +## 1.0.0b69 (unreleased) + +### Fixed + +- The Slow Queries tab's empty-state message now shows the actually-configured + threshold (via `manage_get_slow_query_threshold()`) instead of hard-coding the + `PGCATALOG_SLOW_QUERY_MS` default of 10 ms. + ## 1.0.0b68 (2026-06-30) ### Removed diff --git a/src/plone/pgcatalog/www/catalogSlowQueries.dtml b/src/plone/pgcatalog/www/catalogSlowQueries.dtml index bb12b67..00145d9 100644 --- a/src/plone/pgcatalog/www/catalogSlowQueries.dtml +++ b/src/plone/pgcatalog/www/catalogSlowQueries.dtml @@ -84,8 +84,9 @@

No slow queries recorded yet. - Queries exceeding the threshold (PGCATALOG_SLOW_QUERY_MS, - default 10ms) are logged here automatically. + Queries exceeding the configured threshold + (ms, set via + PGCATALOG_SLOW_QUERY_MS) are logged here automatically.

diff --git a/tests/test_slow_queries_view.py b/tests/test_slow_queries_view.py new file mode 100644 index 0000000..dadc1b5 --- /dev/null +++ b/tests/test_slow_queries_view.py @@ -0,0 +1,27 @@ +"""The Slow Queries empty-state shows the configured threshold, not the default. + +The "no slow queries yet" message used to hard-code the env var name and its +`default 10ms`; it now surfaces the actually-configured threshold via +`manage_get_slow_query_threshold()`. +""" + +import pathlib + + +_DTML = ( + pathlib.Path(__file__).parent.parent + / "src" + / "plone" + / "pgcatalog" + / "www" + / "catalogSlowQueries.dtml" +) + + +def test_empty_state_uses_configured_threshold(): + text = _DTML.read_text() + empty_state = text.split("No slow queries recorded yet.", 1)[1] + # Shows the actual value via the view method ... + assert "manage_get_slow_query_threshold()" in empty_state + # ... and no longer hard-codes the default. + assert "default 10ms" not in empty_state