fix(docker): move dedup helper to a model-free module (CI green)
CI / lint (push) Successful in 3s
CI / unit (push) Successful in 45s
CI / integration (push) Successful in 2m18s
CI / publish (push) Successful in 1m2s

The widget-dedup test imported plugins.docker.routes, which re-imports
plugins.docker.models after the app already loaded the docker plugin —
"Table 'docker_containers' is already defined". Same plugin-loader gotcha the
host_agent query helpers avoid.

Extract dedup_by_container_id into plugins/docker/dedup.py (imports no ORM
models, so it's safe to import in either environment); routes.py imports it
from there and the test targets the model-free module.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016Jg27rgypiW2efULXJDtMC
This commit is contained in:
2026-06-20 23:07:33 -04:00
parent e289b6c49f
commit 431f804037
3 changed files with 32 additions and 23 deletions
+2 -2
View File
@@ -456,14 +456,14 @@ def test_widget_dedup_collapses_cross_manager_duplicates():
the dashboard widget must count it once. Older agents send no container_id,
so those rows can't be matched and are all kept."""
from types import SimpleNamespace
from plugins.docker.routes import _dedup_by_container_id
from plugins.docker.dedup import dedup_by_container_id
def c(cid, name, status="running"):
return SimpleNamespace(container_id=cid, name=name, status=status)
rows = [c("abc", "web@m1"), c("abc", "web@m2"), # same task, two managers
c("def", "db"), c("", "noid-1"), c("", "noid-2")]
out = _dedup_by_container_id(rows)
out = dedup_by_container_id(rows)
assert len(out) == 4 # one "abc" dropped
abc = [r for r in out if r.container_id == "abc"]