Add per_domain flag to report config

This commit is contained in:
Jordan Wages 2025-07-19 00:21:42 -05:00
commit e03c7bc434
3 changed files with 32 additions and 1 deletions

View file

@ -80,6 +80,21 @@ def sample_reports(tmp_path):
FROM logs
GROUP BY bucket
ORDER BY bucket
- name: domain_traffic
per_domain: false
query: |
SELECT host AS bucket,
COUNT(*) AS value
FROM logs
GROUP BY host
ORDER BY value DESC
- name: skip_report
per_domain: false
query: |
SELECT {bucket} AS bucket, COUNT(*) AS value
FROM logs
GROUP BY bucket
ORDER BY bucket
- name: domain_totals
global: true
query: |
@ -113,7 +128,7 @@ def test_generate_interval(tmp_path, sample_reports, monkeypatch):
)
assert error_rate[0]["value"] == pytest.approx(50.0)
reports = json.loads((tmp_path / "output" / "hourly" / "reports.json").read_text())
assert {r["name"] for r in reports} == {"hits", "error_rate"}
assert {r["name"] for r in reports} == {"hits", "error_rate", "skip_report"}
for r in reports:
snippet = tmp_path / "output" / "hourly" / r["html"]
assert snippet.exists()
@ -136,6 +151,18 @@ def test_generate_interval_domain_filter(tmp_path, sample_reports, monkeypatch):
(tmp_path / "output" / "domains" / "example.com" / "hourly" / "hits.json").read_text()
)
assert hits[0]["value"] == 2
reports = json.loads(
(tmp_path / "output" / "domains" / "example.com" / "hourly" / "reports.json").read_text()
)
assert {r["name"] for r in reports} == {"hits", "error_rate"}
assert not (
tmp_path
/ "output"
/ "domains"
/ "example.com"
/ "hourly"
/ "skip_report.json"
).exists()
def test_generate_root_index(tmp_path, sample_reports, monkeypatch):