Organize domain reports under domains directory

This commit is contained in:
Jordan Wages 2025-07-18 02:25:10 -05:00
commit 6b9219009d
3 changed files with 3 additions and 3 deletions

View file

@ -85,7 +85,7 @@ Use the `run-reports.sh` script to run all report intervals in one step. The scr
./run-reports.sh ./run-reports.sh
``` ```
Running this script will create or update the hourly, daily, weekly and monthly reports under `output/`. It also detects all unique domains found in the database and writes per-domain reports to `output/<domain>/<interval>` alongside the aggregate data. Running this script will create or update the hourly, daily, weekly and monthly reports under `output/`. It also detects all unique domains found in the database and writes per-domain reports to `output/domains/<domain>/<interval>` alongside the aggregate data.
## Serving Reports with Nginx ## Serving Reports with Nginx

View file

@ -90,7 +90,7 @@ def _generate_interval(interval: str, domain: Optional[str] = None) -> None:
cur.execute( cur.execute(
f"CREATE TEMP VIEW logs_view AS SELECT * FROM logs WHERE host = '{safe_domain}'" f"CREATE TEMP VIEW logs_view AS SELECT * FROM logs WHERE host = '{safe_domain}'"
) )
out_dir = OUTPUT_DIR / domain / interval out_dir = OUTPUT_DIR / "domains" / domain / interval
else: else:
cur.execute("CREATE TEMP VIEW logs_view AS SELECT * FROM logs") cur.execute("CREATE TEMP VIEW logs_view AS SELECT * FROM logs")
out_dir = OUTPUT_DIR / interval out_dir = OUTPUT_DIR / interval

View file

@ -122,6 +122,6 @@ def test_generate_interval_domain_filter(tmp_path, sample_reports, monkeypatch):
gr._generate_interval("hourly", "example.com") gr._generate_interval("hourly", "example.com")
hits = json.loads( hits = json.loads(
(tmp_path / "output" / "example.com" / "hourly" / "hits.json").read_text() (tmp_path / "output" / "domains" / "example.com" / "hourly" / "hits.json").read_text()
) )
assert hits[0]["value"] == 2 assert hits[0]["value"] == 2