Task ID: task_e_682d3ae763fc8323811a9f1eb5ee8ec4
python-dateutil ------------------------------ 48.00 KiB/224.50 KiB
pytest ------------------------------ 62.88 KiB/335.58 KiB
greenlet ------------------------------ 60.03 KiB/589.71 KiB
pyright ------------------------------ 14.90 KiB/5.31 MiB
ruff ------------------------------ 143.88 KiB/11.02 MiB
duckdb ------------------------------ 112.00 KiB/19.27 MiB
playwright ------------------------------ 8.00 KiB/43.05 MiB
Building scubaduck @ file:///workspace/scubaduck
⠹ Preparing packages... (5/33)
execnet ------------------------------ 32.00 KiB/39.66 KiB
typing-extensions ------------------------------ 44.73 KiB/44.73 KiB
pytest-xdist ------------------------------ 30.91 KiB/45.03 KiB
requests ------------------------------ 14.88 KiB/63.41 KiB
packaging ------------------------------ 62.88 KiB/64.91 KiB
idna ------------------------------ 0 B/68.79 KiB
text-unidecode ------------------------------ 76.32 KiB/76.32 KiB
click ------------------------------ 99.76 KiB/99.76 KiB
flask ------------------------------ 64.00 KiB/100.88 KiB
urllib3 ------------------------------ 35.02 KiB/125.66 KiB
jinja2 ------------------------------ 94.88 KiB/131.74 KiB
charset-normalizer ------------------------------ 125.56 KiB/145.08 KiB
werkzeug ------------------------------ 95.60 KiB/219.24 KiB
python-dateutil ------------------------------ 48.00 KiB/224.50 KiB
pytest ------------------------------ 62.88 KiB/335.58 KiB
greenlet ------------------------------ 60.03 KiB/589.71 KiB
pyright ------------------------------ 14.90 KiB/5.31 MiB
ruff ------------------------------ 143.88 KiB/11.02 MiB
duckdb ------------------------------ 112.00 KiB/19.27 MiB
playwright ------------------------------ 8.00 KiB/43.05 MiB
Building scubaduck @ file:///workspace/scubaduck
⠹ Preparing packages... (5/33)
execnet ------------------------------ 32.00 KiB/39.66 KiB
pytest-xdist ------------------------------ 30.91 KiB/45.03 KiB
requests ------------------------------ 30.88 KiB/63.41 KiB
packaging ------------------------------ 62.88 KiB/64.91 KiB
idna ------------------------------ 0 B/68.79 KiB
text-unidecode ------------------------------ 76.32 KiB/76.32 KiB
click ------------------------------ 99.76 KiB/99.76 KiB
flask ------------------------------ 64.00 KiB/100.88 KiB
urllib3 ------------------------------ 51.02 KiB/125.66 KiB
jinja2 ------------------------------ 110.88 KiB/131.74 KiB
charset-normalizer ------------------------------ 125.56 KiB/145.08 KiB
werkzeug ------------------------------ 95.60 KiB/219.24 KiB
python-dateutil ------------------------------ 48.00 KiB/224.50 KiB
pytest ------------------------------ 62.88 KiB/335.58 KiB
greenlet ------------------------------ 76.03 KiB/589.71 KiB
pyright ------------------------------ 32.00 KiB/5.31 MiB
ruff ------------------------------ 175.88 KiB/11.02 MiB
duckdb ------------------------------ 112.00 KiB/19.27 MiB
playwright ------------------------------ 16.00 KiB/43.05 MiB
Building scubaduck @ file:///workspace/scubaduck
⠹ Preparing packages... (5/33)
execnet ------------------------------ 39.66 KiB/39.66 KiB
pytest-xdist ------------------------------ 45.03 KiB/45.03 KiB
requests ------------------------------ 30.88 KiB/63.41 KiB
idna ------------------------------ 0 B/68.79 KiB
text-unidecode ------------------------------ 76.32 KiB/76.32 KiB
click ------------------------------ 99.76 KiB/99.76 KiB
flask ------------------------------ 64.00 KiB/100.88 KiB
urllib3 ------------------------------ 51.02 KiB/125.66 KiB
jinja2 ------------------------------ 126.88 KiB/131.74 KiB
charset-normalizer ------------------------------ 125.56 KiB/145.08 KiB
werkzeug ------------------------------ 95.60 KiB/219.24 KiB
python-dateutil ------------------------------ 48.00 KiB/224.50 KiB
pytest ------------------------------ 76.53 KiB/335.58 KiB
greenlet ------------------------------ 108.03 KiB/589.71 KiB
pyright ------------------------------ 48.00 KiB/5.31 MiB
ruff ------------------------------ 207.88 KiB/11.02 MiB
duckdb ------------------------------ 128.00 KiB/19.27 MiB
playwright ------------------------------ 16.00 KiB/43.05 MiB
Building scubaduck @ file:///workspace/scubaduck
⠹ Preparing packages... (5/33)
execnet ------------------------------ 39.66 KiB/39.66 KiB
pytest-xdist ------------------------------ 45.03 KiB/45.03 KiB
requests ------------------------------ 30.88 KiB/63.41 KiB
idna ------------------------------ 8.00 KiB/68.79 KiB
text-unidecode ------------------------------ 76.32 KiB/76.32 KiB
flask ------------------------------ 64.00 KiB/100.88 KiB
urllib3 ------------------------------ 51.02 KiB/125.66 KiB
jinja2 ------------------------------ 126.88 KiB/131.74 KiB
charset-normalizer ------------------------------ 125.56 KiB/145.08 KiB
werkzeug ------------------------------ 95.60 KiB/219.24 KiB
python-dateutil ------------------------------ 48.00 KiB/224.50 KiB
pytest ------------------------------ 76.53 KiB/335.58 KiB
greenlet ------------------------------ 124.03 KiB/589.71 KiB
pyright ------------------------------ 60.46 KiB/5.31 MiB
ruff ------------------------------ 223.88 KiB/11.02 MiB
duckdb ------------------------------ 144.00 KiB/19.27 MiB
playwright ------------------------------ 16.00 KiB/43.05 MiB
Building scubaduck @ file:///workspace/scubaduck
⠹ Preparing packages... (5/33)
execnet ------------------------------ 39.66 KiB/39.66 KiB
pytest-xdist ------------------------------ 45.03 KiB/45.03 KiB
requests ------------------------------ 30.88 KiB/63.41 KiB
idna ------------------------------ 8.00 KiB/68.79 KiB
flask ------------------------------ 64.00 KiB/100.88 KiB
urllib3 ------------------------------ 62.72 KiB/125.66 KiB
jinja2 ------------------------------ 126.88 KiB/131.74 KiB
charset-normalizer ------------------------------ 141.56 KiB/145.08 KiB
werkzeug ------------------------------ 111.60 KiB/219.24 KiB
python-dateutil ------------------------------ 76.79 KiB/224.50 KiB
pytest ------------------------------ 92.53 KiB/335.58 KiB
greenlet ------------------------------ 156.03 KiB/589.71 KiB
pyright ------------------------------ 92.46 KiB/5.31 MiB
ruff ------------------------------ 255.88 KiB/11.02 MiB
duckdb ------------------------------ 176.00 KiB/19.27 MiB
playwright ------------------------------ 32.00 KiB/43.05 MiB
Building scubaduck @ file:///workspace/scubaduck
⠹ Preparing packages... (5/33)
execnet ------------------------------ 39.66 KiB/39.66 KiB
pytest-xdist ------------------------------ 45.03 KiB/45.03 KiB
requests ------------------------------ 47.31 KiB/63.41 KiB
idna ------------------------------ 16.00 KiB/68.79 KiB
flask ------------------------------ 80.00 KiB/100.88 KiB
urllib3 ------------------------------ 78.72 KiB/125.66 KiB
jinja2 ------------------------------ 126.88 KiB/131.74 KiB
charset-normalizer ------------------------------ 141.56 KiB/145.08 KiB
werkzeug ------------------------------ 127.60 KiB/219.24 KiB
python-dateutil ------------------------------ 108.79 KiB/224.50 KiB
pytest ------------------------------ 108.53 KiB/335.58 KiB
greenlet ------------------------------ 252.03 KiB/589.71 KiB
pyright ------------------------------ 188.46 KiB/5.31 MiB
ruff ------------------------------ 351.88 KiB/11.02 MiB
duckdb ------------------------------ 272.00 KiB/19.27 MiB
playwright ------------------------------ 32.00 KiB/43.05 MiB
Building scubaduck @ file:///workspace/scubaduck
⠹ Preparing packages... (5/33)
pytest-xdist ------------------------------ 45.03 KiB/45.03 KiB
requests ------------------------------ 47.31 KiB/63.41 KiB
idna ------------------------------ 30.88 KiB/68.79 KiB
flask ------------------------------ 80.00 KiB/100.88 KiB
urllib3 ------------------------------ 78.72 KiB/125.66 KiB
jinja2 ------------------------------ 126.88 KiB/131.74 KiB
charset-normalizer ------------------------------ 141.56 KiB/145.08 KiB
werkzeug ------------------------------ 127.60 KiB/219.24 KiB
python-dateutil ------------------------------ 172.79 KiB/224.50 KiB
pytest ------------------------------ 124.53 KiB/335.58 KiB
greenlet ------------------------------ 316.03 KiB/589.71 KiB
pyright ------------------------------ 236.46 KiB/5.31 MiB
ruff ------------------------------ 399.88 KiB/11.02 MiB
duckdb ------------------------------ 336.00 KiB/19.27 MiB
playwright ------------------------------ 32.00 KiB/43.05 MiB
Building scubaduck @ file:///workspace/scubaduck
⠹ Preparing packages... (5/33)
requests ------------------------------ 63.41 KiB/63.41 KiB
idna ------------------------------ 46.88 KiB/68.79 KiB
flask ------------------------------ 96.00 KiB/100.88 KiB
urllib3 ------------------------------ 78.72 KiB/125.66 KiB
jinja2 ------------------------------ 131.74 KiB/131.74 KiB
charset-normalizer ------------------------------ 145.08 KiB/145.08 KiB
werkzeug ------------------------------ 127.60 KiB/219.24 KiB
python-dateutil ------------------------------ 220.79 KiB/224.50 KiB
pytest ------------------------------ 140.53 KiB/335.58 KiB
greenlet ------------------------------ 380.03 KiB/589.71 KiB
pyright ------------------------------ 332.46 KiB/5.31 MiB
ruff ------------------------------ 479.88 KiB/11.02 MiB
duckdb ------------------------------ 400.00 KiB/19.27 MiB
playwright ------------------------------ 40.52 KiB/43.05 MiB
Building scubaduck @ file:///workspace/scubaduck
⠹ Preparing packages... (5/33)
requests ------------------------------ 63.41 KiB/63.41 KiB
idna ------------------------------ 62.88 KiB/68.79 KiB
flask ------------------------------ 96.00 KiB/100.88 KiB
urllib3 ------------------------------ 78.72 KiB/125.66 KiB
charset-normalizer ------------------------------ 145.08 KiB/145.08 KiB
werkzeug ------------------------------ 127.60 KiB/219.24 KiB
python-dateutil ------------------------------ 220.79 KiB/224.50 KiB
pytest ------------------------------ 140.53 KiB/335.58 KiB
greenlet ------------------------------ 412.03 KiB/589.71 KiB
pyright ------------------------------ 348.46 KiB/5.31 MiB
ruff ------------------------------ 511.88 KiB/11.02 MiB
duckdb ------------------------------ 432.00 KiB/19.27 MiB
playwright ------------------------------ 40.52 KiB/43.05 MiB
Building scubaduck @ file:///workspace/scubaduck
⠹ Preparing packages... (5/33)
requests ------------------------------ 63.41 KiB/63.41 KiB
idna ------------------------------ 68.79 KiB/68.79 KiB
flask ------------------------------ 96.00 KiB/100.88 KiB
urllib3 ------------------------------ 78.72 KiB/125.66 KiB
werkzeug ------------------------------ 143.60 KiB/219.24 KiB
python-dateutil ------------------------------ 220.79 KiB/224.50 KiB
pytest ------------------------------ 140.53 KiB/335.58 KiB
greenlet ------------------------------ 444.03 KiB/589.71 KiB
pyright ------------------------------ 380.46 KiB/5.31 MiB
ruff ------------------------------ 543.88 KiB/11.02 MiB
duckdb ------------------------------ 448.00 KiB/19.27 MiB
playwright ------------------------------ 40.52 KiB/43.05 MiB
Building scubaduck @ file:///workspace/scubaduck
⠹ Preparing packages... (5/33)
idna ------------------------------ 68.79 KiB/68.79 KiB
flask ------------------------------ 96.00 KiB/100.88 KiB
urllib3 ------------------------------ 94.72 KiB/125.66 KiB
werkzeug ------------------------------ 143.60 KiB/219.24 KiB
python-dateutil ------------------------------ 224.50 KiB/224.50 KiB
pytest ------------------------------ 172.53 KiB/335.58 KiB
greenlet ------------------------------ 460.03 KiB/589.71 KiB
pyright ------------------------------ 428.46 KiB/5.31 MiB
ruff ------------------------------ 591.88 KiB/11.02 MiB
duckdb ------------------------------ 496.00 KiB/19.27 MiB
playwright ------------------------------ 56.52 KiB/43.05 MiB
Building scubaduck @ file:///workspace/scubaduck
⠹ Preparing packages... (5/33)
flask ------------------------------ 100.88 KiB/100.88 KiB
urllib3 ------------------------------ 94.72 KiB/125.66 KiB
werkzeug ------------------------------ 143.60 KiB/219.24 KiB
python-dateutil ------------------------------ 224.50 KiB/224.50 KiB
pytest ------------------------------ 172.53 KiB/335.58 KiB
greenlet ------------------------------ 460.03 KiB/589.71 KiB
pyright ------------------------------ 460.46 KiB/5.31 MiB
ruff ------------------------------ 623.88 KiB/11.02 MiB
duckdb ------------------------------ 544.00 KiB/19.27 MiB
playwright ------------------------------ 56.52 KiB/43.05 MiB
Building scubaduck @ file:///workspace/scubaduck
⠹ Preparing packages... (5/33)
flask ------------------------------ 100.88 KiB/100.88 KiB
urllib3 ------------------------------ 94.72 KiB/125.66 KiB
werkzeug ------------------------------ 143.60 KiB/219.24 KiB
pytest ------------------------------ 188.53 KiB/335.58 KiB
greenlet ------------------------------ 460.03 KiB/589.71 KiB
pyright ------------------------------ 492.46 KiB/5.31 MiB
ruff ------------------------------ 655.88 KiB/11.02 MiB
duckdb ------------------------------ 576.00 KiB/19.27 MiB
playwright ------------------------------ 56.52 KiB/43.05 MiB
Building scubaduck @ file:///workspace/scubaduck
⠹ Preparing packages... (5/33)
urllib3 ------------------------------ 94.72 KiB/125.66 KiB
werkzeug ------------------------------ 143.60 KiB/219.24 KiB
pytest ------------------------------ 188.53 KiB/335.58 KiB
greenlet ------------------------------ 460.03 KiB/589.71 KiB
pyright ------------------------------ 492.46 KiB/5.31 MiB
ruff ------------------------------ 655.88 KiB/11.02 MiB
duckdb ------------------------------ 592.00 KiB/19.27 MiB
playwright ------------------------------ 56.52 KiB/43.05 MiB
Building scubaduck @ file:///workspace/scubaduck
⠹ Preparing packages... (5/33)
urllib3 ------------------------------ 94.72 KiB/125.66 KiB
werkzeug ------------------------------ 143.60 KiB/219.24 KiB
pytest ------------------------------ 188.53 KiB/335.58 KiB
greenlet ------------------------------ 476.03 KiB/589.71 KiB
pyright ------------------------------ 588.46 KiB/5.31 MiB
ruff ------------------------------ 751.88 KiB/11.02 MiB
duckdb ------------------------------ 672.00 KiB/19.27 MiB
playwright ------------------------------ 64.00 KiB/43.05 MiB
Building scubaduck @ file:///workspace/scubaduck
⠹ Preparing packages... (5/33)
werkzeug ------------------------------ 191.60 KiB/219.24 KiB
pytest ------------------------------ 236.53 KiB/335.58 KiB
greenlet ------------------------------ 492.03 KiB/589.71 KiB
pyright ------------------------------ 940.46 KiB/5.31 MiB
ruff ------------------------------ 1.08 MiB/11.02 MiB
duckdb ------------------------------ 1.00 MiB/19.27 MiB
playwright ------------------------------ 96.00 KiB/43.05 MiB
Building scubaduck @ file:///workspace/scubaduck
⠹ Preparing packages... (5/33)
werkzeug ------------------------------ 207.60 KiB/219.24 KiB
pytest ------------------------------ 252.53 KiB/335.58 KiB
greenlet ------------------------------ 492.03 KiB/589.71 KiB
pyright ------------------------------ 1.03 MiB/5.31 MiB
ruff ------------------------------ 1.22 MiB/11.02 MiB
duckdb ------------------------------ 1.14 MiB/19.27 MiB
playwright ------------------------------ 112.00 KiB/43.05 MiB
Building scubaduck @ file:///workspace/scubaduck
⠹ Preparing packages... (5/33)
pytest ------------------------------ 268.53 KiB/335.58 KiB
greenlet ------------------------------ 492.03 KiB/589.71 KiB
pyright ------------------------------ 1.19 MiB/5.31 MiB
ruff ------------------------------ 1.37 MiB/11.02 MiB
duckdb ------------------------------ 1.30 MiB/19.27 MiB
playwright ------------------------------ 112.00 KiB/43.05 MiB
Building scubaduck @ file:///workspace/scubaduck
⠹ Preparing packages... (5/33)
pytest ------------------------------ 332.53 KiB/335.58 KiB
greenlet ------------------------------ 524.03 KiB/589.71 KiB
pyright ------------------------------ 1.44 MiB/5.31 MiB
ruff ------------------------------ 1.76 MiB/11.02 MiB
duckdb ------------------------------ 1.67 MiB/19.27 MiB
playwright ------------------------------ 368.00 KiB/43.05 MiB
Building scubaduck @ file:///workspace/scubaduck
⠸ Preparing packages... (26/33)
greenlet ------------------------------ 556.03 KiB/589.71 KiB
pyright ------------------------------ 1.69 MiB/5.31 MiB
ruff ------------------------------ 2.04 MiB/11.02 MiB
duckdb ------------------------------ 1.97 MiB/19.27 MiB
playwright ------------------------------ 667.00 KiB/43.05 MiB
Building scubaduck @ file:///workspace/scubaduck
⠸ Preparing packages... (26/33)
greenlet ------------------------------ 572.03 KiB/589.71 KiB
pyright ------------------------------ 1.78 MiB/5.31 MiB
ruff ------------------------------ 2.27 MiB/11.02 MiB
duckdb ------------------------------ 2.19 MiB/19.27 MiB
playwright ------------------------------ 923.00 KiB/43.05 MiB
Building scubaduck @ file:///workspace/scubaduck
⠸ Preparing packages... (26/33)
pyright ------------------------------ 1.79 MiB/5.31 MiB
ruff ------------------------------ 2.81 MiB/11.02 MiB
duckdb ------------------------------ 2.71 MiB/19.27 MiB
playwright ------------------------------ 1.42 MiB/43.05 MiB
Building scubaduck @ file:///workspace/scubaduck
⠸ Preparing packages... (26/33)
pyright ------------------------------ 1.81 MiB/5.31 MiB
ruff ------------------------------ 3.08 MiB/11.02 MiB
duckdb ------------------------------ 2.99 MiB/19.27 MiB
playwright ------------------------------ 1.67 MiB/43.05 MiB
Building scubaduck @ file:///workspace/scubaduck
⠸ Preparing packages... (26/33)
pyright ------------------------------ 1.84 MiB/5.31 MiB
ruff ------------------------------ 3.81 MiB/11.02 MiB
duckdb ------------------------------ 3.69 MiB/19.27 MiB
playwright ------------------------------ 2.41 MiB/43.05 MiB
Building scubaduck @ file:///workspace/scubaduck
⠸ Preparing packages... (26/33)
pyright ------------------------------ 1.87 MiB/5.31 MiB
ruff ------------------------------ 4.53 MiB/11.02 MiB
duckdb ------------------------------ 4.39 MiB/19.27 MiB
playwright ------------------------------ 3.09 MiB/43.05 MiB
Building scubaduck @ file:///workspace/scubaduck
⠼ Preparing packages... (28/33)
pyright ------------------------------ 1.92 MiB/5.31 MiB
ruff ------------------------------ 5.23 MiB/11.02 MiB
duckdb ------------------------------ 5.09 MiB/19.27 MiB
playwright ------------------------------ 3.83 MiB/43.05 MiB
Building scubaduck @ file:///workspace/scubaduck
⠼ Preparing packages... (28/33)
pyright ------------------------------ 1.95 MiB/5.31 MiB
ruff ------------------------------ 6.06 MiB/11.02 MiB
duckdb ------------------------------ 5.91 MiB/19.27 MiB
playwright ------------------------------ 4.64 MiB/43.05 MiB
Building scubaduck @ file:///workspace/scubaduck
⠼ Preparing packages... (28/33)
pyright ------------------------------ 1.98 MiB/5.31 MiB
ruff ------------------------------ 6.84 MiB/11.02 MiB
duckdb ------------------------------ 6.67 MiB/19.27 MiB
playwright ------------------------------ 5.41 MiB/43.05 MiB
Building scubaduck @ file:///workspace/scubaduck
⠼ Preparing packages... (28/33)
pyright ------------------------------ 2.02 MiB/5.31 MiB
ruff ------------------------------ 7.51 MiB/11.02 MiB
duckdb ------------------------------ 7.34 MiB/19.27 MiB
playwright ------------------------------ 6.08 MiB/43.05 MiB
Building scubaduck @ file:///workspace/scubaduck
⠴ Preparing packages... (28/33)
pyright ------------------------------ 2.06 MiB/5.31 MiB
ruff ------------------------------ 8.27 MiB/11.02 MiB
duckdb ------------------------------ 8.09 MiB/19.27 MiB
playwright ------------------------------ 6.84 MiB/43.05 MiB
Building scubaduck @ file:///workspace/scubaduck
⠴ Preparing packages... (28/33)
pyright ------------------------------ 2.09 MiB/5.31 MiB
ruff ------------------------------ 9.05 MiB/11.02 MiB
duckdb ------------------------------ 8.86 MiB/19.27 MiB
playwright ------------------------------ 7.61 MiB/43.05 MiB
Building scubaduck @ file:///workspace/scubaduck
⠴ Preparing packages... (28/33)
pyright ------------------------------ 2.12 MiB/5.31 MiB
ruff ------------------------------ 9.83 MiB/11.02 MiB
duckdb ------------------------------ 9.68 MiB/19.27 MiB
playwright ------------------------------ 8.40 MiB/43.05 MiB
Building scubaduck @ file:///workspace/scubaduck
⠴ Preparing packages... (28/33)
pyright ------------------------------ 2.14 MiB/5.31 MiB
ruff ------------------------------ 10.65 MiB/11.02 MiB
duckdb ------------------------------ 10.49 MiB/19.27 MiB
playwright ------------------------------ 9.23 MiB/43.05 MiB
Building scubaduck @ file:///workspace/scubaduck
⠦ Preparing packages... (28/33)
pyright ------------------------------ 2.14 MiB/5.31 MiB
duckdb ------------------------------ 10.92 MiB/19.27 MiB
playwright ------------------------------ 9.66 MiB/43.05 MiB
Building scubaduck @ file:///workspace/scubaduck
⠦ Preparing packages... (28/33)
pyright ------------------------------ 2.16 MiB/5.31 MiB
duckdb ------------------------------ 11.22 MiB/19.27 MiB
playwright ------------------------------ 9.96 MiB/43.05 MiB
Built scubaduck @ file:///workspace/scubaduck
⠦ Preparing packages... (28/33)
pyright ------------------------------ 2.16 MiB/5.31 MiB
duckdb ------------------------------ 11.44 MiB/19.27 MiB
playwright ------------------------------ 10.17 MiB/43.05 MiB
⠦ Preparing packages... (28/33)
pyright ------------------------------ 2.17 MiB/5.31 MiB
duckdb ------------------------------ 12.02 MiB/19.27 MiB
playwright ------------------------------ 10.77 MiB/43.05 MiB
⠦ Preparing packages... (28/33)
pyright ------------------------------ 2.17 MiB/5.31 MiB
duckdb ------------------------------ 12.93 MiB/19.27 MiB
playwright ------------------------------ 11.66 MiB/43.05 MiB
⠦ Preparing packages... (28/33)
pyright ------------------------------ 2.19 MiB/5.31 MiB
duckdb ------------------------------ 13.81 MiB/19.27 MiB
playwright ------------------------------ 12.56 MiB/43.05 MiB
⠧ Preparing packages... (30/33)
pyright ------------------------------ 2.20 MiB/5.31 MiB
duckdb ------------------------------ 15.06 MiB/19.27 MiB
playwright ------------------------------ 13.81 MiB/43.05 MiB
⠧ Preparing packages... (30/33)
pyright ------------------------------ 2.22 MiB/5.31 MiB
duckdb ------------------------------ 15.96 MiB/19.27 MiB
playwright ------------------------------ 14.72 MiB/43.05 MiB
⠧ Preparing packages... (30/33)
pyright ------------------------------ 2.23 MiB/5.31 MiB
duckdb ------------------------------ 17.04 MiB/19.27 MiB
playwright ------------------------------ 15.84 MiB/43.05 MiB
⠧ Preparing packages... (30/33)
pyright ------------------------------ 2.25 MiB/5.31 MiB
duckdb ------------------------------ 18.04 MiB/19.27 MiB
playwright ------------------------------ 16.81 MiB/43.05 MiB
⠇ Preparing packages... (30/33)
pyright ------------------------------ 2.26 MiB/5.31 MiB
duckdb ------------------------------ 18.94 MiB/19.27 MiB
playwright ------------------------------ 17.73 MiB/43.05 MiB
⠇ Preparing packages... (30/33)
pyright ------------------------------ 2.31 MiB/5.31 MiB
duckdb ------------------------------ 19.27 MiB/19.27 MiB
playwright ------------------------------ 19.14 MiB/43.05 MiB
⠇ Preparing packages... (30/33)
pyright ------------------------------ 2.34 MiB/5.31 MiB
playwright ------------------------------ 19.67 MiB/43.05 MiB
⠇ Preparing packages... (30/33)
pyright ------------------------------ 2.37 MiB/5.31 MiB
playwright ------------------------------ 20.98 MiB/43.05 MiB
⠇ Preparing packages... (30/33)
pyright ------------------------------ 2.40 MiB/5.31 MiB
playwright ------------------------------ 23.20 MiB/43.05 MiB
⠋ Preparing packages... (31/33)
pyright ------------------------------ 2.44 MiB/5.31 MiB
playwright ------------------------------ 25.50 MiB/43.05 MiB
⠋ Preparing packages... (31/33)
pyright ------------------------------ 2.45 MiB/5.31 MiB
playwright ------------------------------ 27.64 MiB/43.05 MiB
⠋ Preparing packages... (31/33)
pyright ------------------------------ 2.47 MiB/5.31 MiB
playwright ------------------------------ 30.12 MiB/43.05 MiB
⠋ Preparing packages... (31/33)
pyright ------------------------------ 2.50 MiB/5.31 MiB
playwright ------------------------------ 32.23 MiB/43.05 MiB
⠙ Preparing packages... (31/33)
pyright ------------------------------ 2.51 MiB/5.31 MiB
playwright ------------------------------ 33.95 MiB/43.05 MiB
⠙ Preparing packages... (31/33)
pyright ------------------------------ 2.56 MiB/5.31 MiB
playwright ------------------------------ 36.17 MiB/43.05 MiB
⠙ Preparing packages... (31/33)
pyright ------------------------------ 2.59 MiB/5.31 MiB
playwright ------------------------------ 38.32 MiB/43.05 MiB
⠙ Preparing packages... (31/33)
pyright ------------------------------ 2.61 MiB/5.31 MiB
playwright ------------------------------ 40.18 MiB/43.05 MiB
⠹ Preparing packages... (31/33)
pyright ------------------------------ 2.65 MiB/5.31 MiB
playwright ------------------------------ 41.04 MiB/43.05 MiB
⠹ Preparing packages... (31/33)
pyright ------------------------------ 2.75 MiB/5.31 MiB
playwright ------------------------------ 41.57 MiB/43.05 MiB
⠹ Preparing packages... (31/33)
pyright ------------------------------ 2.80 MiB/5.31 MiB
playwright ------------------------------ 43.01 MiB/43.05 MiB
⠹ Preparing packages... (31/33)
pyright ------------------------------ 2.80 MiB/5.31 MiB
⠹ Preparing packages... (31/33)
pyright ------------------------------ 2.95 MiB/5.31 MiB
⠸ Preparing packages... (32/33)
pyright ------------------------------ 3.14 MiB/5.31 MiB
⠸ Preparing packages... (32/33)
pyright ------------------------------ 3.28 MiB/5.31 MiB
⠸ Preparing packages... (32/33)
pyright ------------------------------ 3.47 MiB/5.31 MiB
⠼ Preparing packages... (32/33)
pyright ------------------------------ 3.69 MiB/5.31 MiB
⠼ Preparing packages... (32/33)
pyright ------------------------------ 3.84 MiB/5.31 MiB
⠼ Preparing packages... (32/33)
pyright ------------------------------ 4.17 MiB/5.31 MiB
⠼ Preparing packages... (32/33)
pyright ------------------------------ 4.37 MiB/5.31 MiB
⠼ Preparing packages... (32/33)
pyright ------------------------------ 4.50 MiB/5.31 MiB
⠴ Preparing packages... (32/33)
Prepared 33 packages in 2.64s
░░░░░░░░░░░░░░░░░░░░ [0/0] Installing wheels...
░░░░░░░░░░░░░░░░░░░░ [0/33] Installing wheels...
░░░░░░░░░░░░░░░░░░░░ [0/33] markupsafe==3.0.2
░░░░░░░░░░░░░░░░░░░░ [1/33] markupsafe==3.0.2
░░░░░░░░░░░░░░░░░░░░ [1/33] six==1.17.0
█░░░░░░░░░░░░░░░░░░░ [2/33] six==1.17.0
█░░░░░░░░░░░░░░░░░░░ [2/33] execnet==2.1.1
█░░░░░░░░░░░░░░░░░░░ [3/33] execnet==2.1.1
█░░░░░░░░░░░░░░░░░░░ [3/33] iniconfig==2.1.0
██░░░░░░░░░░░░░░░░░░ [4/33] iniconfig==2.1.0
██░░░░░░░░░░░░░░░░░░ [4/33] nodeenv==1.9.1
███░░░░░░░░░░░░░░░░░ [5/33] nodeenv==1.9.1
███░░░░░░░░░░░░░░░░░ [5/33] pytest-base-url==2.1.0
███░░░░░░░░░░░░░░░░░ [6/33] pytest-base-url==2.1.0
███░░░░░░░░░░░░░░░░░ [6/33] pytest-xdist==3.6.1
████░░░░░░░░░░░░░░░░ [7/33] pytest-xdist==3.6.1
████░░░░░░░░░░░░░░░░ [7/33] itsdangerous==2.2.0
████░░░░░░░░░░░░░░░░ [8/33] itsdangerous==2.2.0
████░░░░░░░░░░░░░░░░ [8/33] pyee==13.0.0
█████░░░░░░░░░░░░░░░ [9/33] pyee==13.0.0
███████████████████░ [32/33] pyright==1.1.400
████████████████████ [33/33] pyright==1.1.400
Installed 33 packages in 113ms
+ blinker==1.9.0
+ certifi==2025.4.26
+ charset-normalizer==3.4.2
+ click==8.2.0
+ duckdb==1.2.2
+ execnet==2.1.1
+ flask==3.1.1
+ greenlet==3.2.2
+ idna==3.10
+ iniconfig==2.1.0
+ itsdangerous==2.2.0
+ jinja2==3.1.6
+ markupsafe==3.0.2
+ nodeenv==1.9.1
+ packaging==25.0
+ playwright==1.52.0
+ pluggy==1.6.0
+ pyee==13.0.0
+ pyright==1.1.400
+ pytest==8.3.5
+ pytest-base-url==2.1.0
+ pytest-playwright==0.7.0
+ pytest-xdist==3.6.1
+ python-dateutil==2.9.0.post0
+ python-slugify==8.0.4
+ requests==2.32.3
+ ruff==0.11.10
+ scubaduck==0.1.0 (from file:///workspace/scubaduck)
+ six==1.17.0
+ text-unidecode==1.3
+ typing-extensions==4.13.2
+ urllib3==2.4.0
+ werkzeug==3.1.3
++ source .venv/bin/activate
+++ '[' -z '' ']'
+++ '[' -n x ']'
+++ SCRIPT_PATH=.venv/bin/activate
+++ '[' .venv/bin/activate = /tmp/Qduigc-setup_script.sh ']'
+++ deactivate nondestructive
+++ unset -f pydoc
+++ '[' -z '' ']'
+++ '[' -z '' ']'
+++ hash -r
+++ '[' -z '' ']'
+++ unset VIRTUAL_ENV
+++ unset VIRTUAL_ENV_PROMPT
+++ '[' '!' nondestructive = nondestructive ']'
+++ VIRTUAL_ENV=/workspace/scubaduck/.venv
+++ '[' linux-gnu = cygwin ']'
+++ '[' linux-gnu = msys ']'
+++ export VIRTUAL_ENV
+++ '[' -z '' ']'
+++ unset SCRIPT_PATH
+++ _OLD_VIRTUAL_PATH=/root/.cargo/bin:/root/.rbenv/shims:/root/.rbenv/bin:/root/.rbenv/shims:/root/.local/share/swiftly/bin:/root/.bun/bin:/root/.nvm/versions/node/v22.15.1/bin:/root/.pyenv/shims:3441PYENV_ROOT/shims:/root/.pyenv/bin:/usr/local/go/bin:/root/go/bin:/root/.rbenv/bin:/root/.rbenv/shims:/root/.bun/bin:/root/.local/bin:/root/.pyenv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
+++ PATH=/workspace/scubaduck/.venv/bin:/root/.cargo/bin:/root/.rbenv/shims:/root/.rbenv/bin:/root/.rbenv/shims:/root/.local/share/swiftly/bin:/root/.bun/bin:/root/.nvm/versions/node/v22.15.1/bin:/root/.pyenv/shims:3441PYENV_ROOT/shims:/root/.pyenv/bin:/usr/local/go/bin:/root/go/bin:/root/.rbenv/bin:/root/.rbenv/shims:/root/.bun/bin:/root/.local/bin:/root/.pyenv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
+++ export PATH
+++ '[' xscubaduck '!=' x ']'
+++ VIRTUAL_ENV_PROMPT='(scubaduck) '
+++ export VIRTUAL_ENV_PROMPT
+++ '[' -z '' ']'
+++ '[' -z '' ']'
+++ _OLD_VIRTUAL_PS1=
+++ PS1='(scubaduck) '
+++ export PS1
+++ alias pydoc
+++ true
+++ hash -r
++ playwright install chromium
Downloading Chromium 136.0.7103.25 (playwright build v1169) from https://cdn.playwright.dev/dbazure/download/playwright/builds/chromium/1169/chromium-linux.zip
167.7 MiB [] 0% 0.0s167.7 MiB [] 0% 21.4s167.7 MiB [] 0% 11.6s167.7 MiB [] 0% 8.2s167.7 MiB [] 1% 6.0s167.7 MiB [] 1% 4.8s167.7 MiB [] 2% 4.1s167.7 MiB [] 3% 3.6s167.7 MiB [] 4% 2.8s167.7 MiB [] 5% 2.6s167.7 MiB [] 6% 2.5s167.7 MiB [] 7% 2.3s167.7 MiB [] 9% 2.1s167.7 MiB [] 10% 2.0s167.7 MiB [] 11% 1.9s167.7 MiB [] 12% 1.9s167.7 MiB [] 13% 1.8s167.7 MiB [] 14% 1.8s167.7 MiB [] 15% 1.7s167.7 MiB [] 16% 1.7s167.7 MiB [] 17% 1.7s167.7 MiB [] 19% 1.6s167.7 MiB [] 20% 1.5s167.7 MiB [] 21% 1.4s167.7 MiB [] 22% 1.4s167.7 MiB [] 24% 1.4s167.7 MiB [] 25% 1.3s167.7 MiB [] 26% 1.3s167.7 MiB [] 27% 1.3s167.7 MiB [] 28% 1.3s167.7 MiB [] 30% 1.2s167.7 MiB [] 31% 1.2s167.7 MiB [] 33% 1.1s167.7 MiB [] 34% 1.1s167.7 MiB [] 35% 1.1s167.7 MiB [] 37% 1.0s167.7 MiB [] 38% 1.0s167.7 MiB [] 40% 0.9s167.7 MiB [] 41% 0.9s167.7 MiB [] 43% 0.9s167.7 MiB [] 45% 0.8s167.7 MiB [] 46% 0.8s167.7 MiB [] 48% 0.8s167.7 MiB [] 49% 0.7s167.7 MiB [] 51% 0.7s167.7 MiB [] 53% 0.7s167.7 MiB [] 55% 0.6s167.7 MiB [] 56% 0.6s167.7 MiB [] 58% 0.6s167.7 MiB [] 59% 0.6s167.7 MiB [] 60% 0.6s167.7 MiB [] 62% 0.5s167.7 MiB [] 64% 0.5s167.7 MiB [] 66% 0.5s167.7 MiB [] 67% 0.4s167.7 MiB [] 68% 0.4s167.7 MiB [] 69% 0.4s167.7 MiB [] 70% 0.4s167.7 MiB [] 72% 0.4s167.7 MiB [] 73% 0.4s167.7 MiB [] 75% 0.3s167.7 MiB [] 76% 0.3s167.7 MiB [] 78% 0.3s167.7 MiB [] 79% 0.3s167.7 MiB [] 80% 0.3s167.7 MiB [] 82% 0.2s167.7 MiB [] 83% 0.2s167.7 MiB [] 84% 0.2s167.7 MiB [] 85% 0.2s167.7 MiB [] 87% 0.2s167.7 MiB [] 88% 0.2s167.7 MiB [] 89% 0.1s167.7 MiB [] 90% 0.1s167.7 MiB [] 91% 0.1s167.7 MiB [] 92% 0.1s167.7 MiB [] 93% 0.1s167.7 MiB [] 94% 0.1s167.7 MiB [] 96% 0.1s167.7 MiB [] 97% 0.0s167.7 MiB [] 98% 0.0s167.7 MiB [] 99% 0.0s167.7 MiB [] 100% 0.0s
Chromium 136.0.7103.25 (playwright build v1169) downloaded to /root/.cache/ms-playwright/chromium-1169
Downloading FFMPEG playwright build v1011 from https://cdn.playwright.dev/dbazure/download/playwright/builds/ffmpeg/1011/ffmpeg-linux.zip
2.3 MiB [] 0% 0.0s2.3 MiB [] 5% 0.3s2.3 MiB [] 15% 0.2s2.3 MiB [] 34% 0.1s2.3 MiB [] 47% 0.1s2.3 MiB [] 100% 0.0s
FFMPEG playwright build v1011 downloaded to /root/.cache/ms-playwright/ffmpeg-1011
Downloading Chromium Headless Shell 136.0.7103.25 (playwright build v1169) from https://cdn.playwright.dev/dbazure/download/playwright/builds/chromium/1169/chromium-headless-shell-linux.zip
101.4 MiB [] 0% 0.0s101.4 MiB [] 0% 17.3s101.4 MiB [] 0% 20.7s101.4 MiB [] 0% 14.0s101.4 MiB [] 0% 10.0s101.4 MiB [] 1% 7.5s101.4 MiB [] 1% 5.2s101.4 MiB [] 3% 3.4s101.4 MiB [] 4% 2.9s101.4 MiB [] 6% 2.4s101.4 MiB [] 7% 2.0s101.4 MiB [] 9% 1.9s101.4 MiB [] 10% 1.8s101.4 MiB [] 11% 1.7s101.4 MiB [] 14% 1.4s101.4 MiB [] 16% 1.3s101.4 MiB [] 19% 1.1s101.4 MiB [] 22% 1.0s101.4 MiB [] 24% 0.9s101.4 MiB [] 27% 0.8s101.4 MiB [] 29% 0.8s101.4 MiB [] 31% 0.8s101.4 MiB [] 33% 0.7s101.4 MiB [] 35% 0.7s101.4 MiB [] 38% 0.6s101.4 MiB [] 41% 0.6s101.4 MiB [] 43% 0.6s101.4 MiB [] 45% 0.5s101.4 MiB [] 47% 0.5s101.4 MiB [] 51% 0.5s101.4 MiB [] 55% 0.4s101.4 MiB [] 56% 0.4s101.4 MiB [] 59% 0.4s101.4 MiB [] 61% 0.3s101.4 MiB [] 64% 0.3s101.4 MiB [] 67% 0.3s101.4 MiB [] 69% 0.3s101.4 MiB [] 71% 0.2s101.4 MiB [] 75% 0.2s101.4 MiB [] 78% 0.2s101.4 MiB [] 81% 0.1s101.4 MiB [] 84% 0.1s101.4 MiB [] 87% 0.1s101.4 MiB [] 89% 0.1s101.4 MiB [] 91% 0.1s101.4 MiB [] 94% 0.0s101.4 MiB [] 97% 0.0s101.4 MiB [] 99% 0.0s101.4 MiB [] 100% 0.0s
Chromium Headless Shell 136.0.7103.25 (playwright build v1169) downloaded to /root/.cache/ms-playwright/chromium_headless_shell-1169
++ echo 'source .venv/bin/activate'
I'll start by reading the AGENTS.md file located at the repo's root.
bash: .venv/bin/activate: No such file or directory
root@947ba2ae34e4:/workspace# ls
scubaduck
Switching to the scubaduck directory now.
root@947ba2ae34e4:/workspace# cd scubaduck
root@947ba2ae34e4:/workspace/scubaduck# ls
AGENTS.md codex_setup.sh scubaduck tests
README.md pyproject.toml stubs uv.lock
I'll review AGENTS.md for any relevant instructions or guidelines.
root@947ba2ae34e4:/workspace/scubaduck# cat AGENTS.md
- Use "source .venv/bin/activate" to activate the virtual environment before
running any commands
- ONLY use non-interactive commands like cat, sed, apply_patch to do edits.
Do NOT use interactive editors.
- Do NOT attempt to install packages. Only the packages specified in
pyproject.toml are available. You cannot add new packages. If you
desperately want another package, make a note of it in the final PR
description.
- Use conventional commits to format PR title
- There are no nested AGENTS.md files, this is the only agents file
- When using Playwright, ONLY use chromium browser. This browser is already
installed.
- Use "ruff check" to check lint, "ruff format" to autoformat files and
"pyright" to typecheck.
- When writing the PR description, include the original prompt supplied by the
user.
- When you add functionality to the server, add server tests to
tests/test_server.py. When you add features to the frontend, add frontend
tests to tests/test_web.py
I'll activate the .venv environment, then inspect the repo and tests to understand the setup.
root@947ba2ae34e4:/workspace/scubaduck# ls tests
conftest.py test_server.py test_web.py
I'm starting with the test file tests/test_web.py.
root@947ba2ae34e4:/workspace/scubaduck# sed -n '1,160p' tests/test_web.py
from __future__ import annotations
from typing import Any
def select_value(page: Any, selector: str, value: str) -> None:
page.evaluate(
"arg => setSelectValue(arg.sel, arg.val)",
{"sel": selector, "val": value},
)
def run_query(
page: Any,
url: str,
*,
start: str | None = None,
end: str | None = None,
order_by: str | None = None,
order_dir: str | None = "ASC",
limit: int | None = None,
group_by: list[str] | None = None,
aggregate: str | None = None,
) -> dict[str, Any]:
page.goto(url)
page.wait_for_selector("#order_by option", state="attached")
page.wait_for_selector("#order_dir", state="attached")
page.wait_for_function("window.lastResults !== undefined")
if start is not None:
page.fill("#start", start)
if end is not None:
page.fill("#end", end)
if order_by is not None:
select_value(page, "#order_by", order_by)
if order_dir is not None and order_dir == "DESC":
page.click("#order_dir")
if limit is not None:
page.fill("#limit", str(limit))
if group_by is not None:
select_value(page, "#graph_type", "table")
page.evaluate(
"g => { groupBy.chips = g; groupBy.renderChips(); }",
group_by,
)
if aggregate is not None:
select_value(page, "#graph_type", "table")
select_value(page, "#aggregate", aggregate)
page.evaluate("window.lastResults = undefined")
page.click("text=Dive")
page.wait_for_function("window.lastResults !== undefined")
return page.evaluate("window.lastResults")
def test_range_filters(page: Any, server_url: str) -> None:
data = run_query(
page,
server_url,
start="2024-01-02 00:00:00",
end="2024-01-02 04:00:00",
order_by="timestamp",
limit=100,
)
assert len(data["rows"]) == 2
from dateutil import parser
timestamps = [parser.parse(row[0]).replace(tzinfo=None) for row in data["row
s"]]
assert timestamps == [
parser.parse("2024-01-02 00:00:00"),
parser.parse("2024-01-02 03:00:00"),
]
def test_order_by(page: Any, server_url: str) -> None:
data = run_query(
page,
server_url,
start="2024-01-01 00:00:00",
end="2024-01-03 00:00:00",
order_by="value",
order_dir="DESC",
limit=100,
)
values = [row[2] for row in data["rows"]]
assert values == sorted(values, reverse=True)
def test_limit(page: Any, server_url: str) -> None:
data = run_query(
page,
server_url,
start="2024-01-01 00:00:00",
end="2024-01-03 00:00:00",
order_by="timestamp",
limit=2,
)
assert len(data["rows"]) == 2
def test_simple_filter(page: Any, server_url: str) -> None:
page.goto(server_url)
page.wait_for_selector("#order_by option", state="attached")
page.click("text=Add Filter")
filter_el = page.query_selector("#filters .filter:last-child")
assert filter_el
page.evaluate(
"arg => setSelectValue(arg.el.querySelector('.f-col'), arg.val)",
{"el": filter_el, "val": "user"},
)
val_input = filter_el.query_selector(".f-val")
val_input.click()
page.keyboard.type("alice")
page.keyboard.press("Enter")
page.click("text=Dive")
page.wait_for_function("window.lastResults !== undefined")
data = page.evaluate("window.lastResults")
assert len(data["rows"]) == 2
assert all(row[3] == "alice" for row in data["rows"])
def test_default_filter_and_layout(page: Any, server_url: str) -> None:
page.goto(server_url)
page.wait_for_selector("#order_by option", state="attached")
count = page.evaluate("document.querySelectorAll('#filters .filter').length"
)
assert count == 1
last_is_button = page.evaluate(
"document.querySelector('#filters').lastElementChild.id === 'add_filter'
"
)
assert last_is_button
position = page.evaluate(
"getComputedStyle(document.querySelector('#filters .filter button.remove
')).position"
)
assert position == "static"
def test_header_and_tabs(page: Any, server_url: str) -> None:
page.goto(server_url)
page.wait_for_selector("#order_by option", state="attached")
header = page.text_content("#header")
assert "sample.csv" in header
assert "events" in header
assert page.is_visible("#settings")
assert page.is_hidden("#columns")
page.click("text=Columns")
assert page.is_visible("#columns")
cols = [c.strip() for c in page.locator("#column_groups li").all_inner_texts
()]
assert "timestamp" in cols
assert "event" in cols
page.click("text=View Settings")
assert page.is_visible("#settings")
btn_color = page.evaluate(
"getComputedStyle(document.querySelector('#dive')).backgroundColor"
)
assert "rgb(0, 128, 0)" == btn_color
sidebar_overflow = page.evaluate(
"getComputedStyle(document.querySelector('#sidebar')).overflowY"
)
root@947ba2ae34e4:/workspace/scubaduck# sed -n '160,320p' tests/test_web.py
)
view_overflow = page.evaluate(
"getComputedStyle(document.querySelector('#view')).overflowY"
)
assert sidebar_overflow == "auto"
assert view_overflow == "auto"
def test_graph_type_table_fields(page: Any, server_url: str) -> None:
page.goto(server_url)
page.wait_for_selector("#graph_type", state="attached")
select_value(page, "#graph_type", "table")
assert page.is_visible("#group_by_field")
assert page.is_visible("#aggregate_field")
assert page.is_visible("#show_hits_field")
page.click("text=Columns")
assert not page.is_visible("text=Strings:")
def test_help_and_alignment(page: Any, server_url: str) -> None:
page.goto(server_url)
page.wait_for_selector("#order_by option", state="attached")
titles = page.evaluate(
"Array.from(document.querySelectorAll('#settings .help')).map(e => e.tit
le)"
)
assert any("start/end of the time range" in t for t in titles)
text_align = page.evaluate(
"getComputedStyle(document.querySelector('#settings label')).textAlign"
)
assert text_align == "right"
def test_table_sorting(page: Any, server_url: str) -> None:
run_query(
page,
server_url,
start="2024-01-01 00:00:00",
end="2024-01-03 00:00:00",
order_by="timestamp",
order_dir="ASC",
limit=100,
)
# header alignment
align = page.evaluate(
"getComputedStyle(document.querySelector('#results th')).textAlign"
)
assert align == "right"
header = page.locator("#results th").nth(3)
def values() -> list[str]:
return page.locator("#results td:nth-child(4)").all_inner_texts()
orig_rows = values()
assert orig_rows == ["alice", "bob", "alice", "charlie"]
first_sql = page.evaluate("window.lastResults.sql")
header.click()
assert values() == sorted(orig_rows)
assert header.inner_text().endswith("▲")
color = page.evaluate(
"getComputedStyle(document.querySelector('#results th:nth-child(4)')).co
lor"
)
assert "0, 0, 255" in color
assert page.evaluate("window.lastResults.sql") == first_sql
header.click()
assert values() == sorted(orig_rows, reverse=True)
assert header.inner_text().endswith("▼")
header.click()
assert values() == orig_rows
assert header.inner_text() == "user"
color = page.evaluate(
"getComputedStyle(document.querySelector('#results th:nth-child(4)')).co
lor"
)
assert "0, 0, 255" not in color
def test_relative_dropdown(page: Any, server_url: str) -> None:
page.goto(server_url)
page.wait_for_selector("#order_by option", state="attached")
btn = page.query_selector('[data-target="start-select"]')
assert btn
btn.click()
page.click("#start-select div:text('-3 hours')")
assert page.input_value("#start") == "-3 hours"
def test_end_dropdown_now(page: Any, server_url: str) -> None:
page.goto(server_url)
page.wait_for_selector("#order_by option", state="attached")
page.click('[data-target="end-select"]')
page.click("#end-select div:text('now')")
assert page.input_value("#end") == "now"
def test_invalid_time_error_shown(page: Any, server_url: str) -> None:
data = run_query(
page,
server_url,
start="nonsense",
end="now",
order_by="timestamp",
)
assert "error" in data
msg = page.text_content("#view")
assert "nonsense" in msg
def test_query_error_shown(page: Any, server_url: str) -> None:
data = run_query(
page,
server_url,
start="2024-01-01 00:00:00",
end="2024-01-03 00:00:00",
order_by="timestamp",
group_by=["user"],
aggregate="Avg",
)
assert "error" in data
msg = page.text_content("#view")
assert "Aggregate avg" in msg
def test_column_toggle_and_selection(page: Any, server_url: str) -> None:
page.goto(server_url)
page.wait_for_selector("#order_by option", state="attached")
page.click("text=Columns")
page.wait_for_selector("#column_groups input", state="attached")
count = page.evaluate(
"document.querySelectorAll('#column_groups input:checked').length"
)
assert count == 4
page.click("#columns_none")
count = page.evaluate(
"document.querySelectorAll('#column_groups input:checked').length"
)
assert count == 0
page.click("#columns_all")
count = page.evaluate(
"document.querySelectorAll('#column_groups input:checked').length"
)
assert count == 4
page.uncheck("#column_groups input[value='value']")
page.click("text=View Settings")
page.fill("#start", "2024-01-01 00:00:00")
page.fill("#end", "2024-01-02 00:00:00")
select_value(page, "#order_by", "timestamp")
page.fill("#limit", "10")
page.evaluate("window.lastResults = undefined")
page.click("text=Dive")
page.wait_for_function("window.lastResults !== undefined")
data = page.evaluate("window.lastResults")
assert len(data["rows"][0]) == 3
headers = page.locator("#results th").all_inner_texts()
root@947ba2ae34e4:/workspace/scubaduck# sed -n '320,640p' tests/test_web.py
headers = page.locator("#results th").all_inner_texts()
assert "value" not in headers
def test_columns_links_alignment(page: Any, server_url: str) -> None:
page.goto(server_url)
page.wait_for_selector("#order_by option", state="attached")
page.click("text=Columns")
page.wait_for_selector("#column_groups input", state="attached")
tag = page.evaluate("document.getElementById('columns_all').tagName")
assert tag == "A"
align = page.evaluate(
"getComputedStyle(document.querySelector('#column_actions')).textAlign"
)
assert align == "right"
def test_column_group_links(page: Any, server_url: str) -> None:
page.goto(server_url)
page.wait_for_selector("#order_by option", state="attached")
page.click("text=Columns")
page.wait_for_selector("#column_groups a", state="attached")
tag = page.evaluate("document.querySelector('#column_groups .col-group a').t
agName")
assert tag == "A"
def test_column_group_links_float_right(page: Any, server_url: str) -> None:
page.goto(server_url)
page.wait_for_selector("#order_by option", state="attached")
page.click("text=Columns")
page.wait_for_selector("#column_groups .col-group .links", state="attached")
float_val = page.evaluate(
"getComputedStyle(document.querySelector('#column_groups .col-group .lin
ks')).float"
)
assert float_val == "right"
def test_chip_dropdown_navigation(page: Any, server_url: str) -> None:
page.goto(server_url)
page.wait_for_selector("#order_by option", state="attached")
page.click("text=Add Filter")
f = page.query_selector("#filters .filter:last-child")
assert f
page.evaluate(
"arg => setSelectValue(arg.el.querySelector('.f-col'), arg.val)",
{"el": f, "val": "user"},
)
inp = f.query_selector(".f-val")
inp.click()
page.wait_for_selector("#filters .filter:last-child .chip-dropdown div")
page.keyboard.type("ali")
page.wait_for_selector("text=alice")
page.keyboard.press("ArrowDown")
page.keyboard.press("Enter")
chips = page.evaluate(
"Array.from(document.querySelectorAll('#filters .filter:last-child .chip
')).map(c => c.firstChild.textContent)"
)
assert chips == ["ali"]
page.click("#filters .filter:last-child .chip .x")
page.wait_for_selector(".chip", state="detached")
def test_chip_copy_and_paste(page: Any, server_url: str) -> None:
page.goto(server_url)
page.wait_for_selector("#order_by option", state="attached")
page.evaluate(
"Object.defineProperty(navigator, 'clipboard', {value:{ _data: '', write
Text(t){ this._data = t; }, readText(){ return Promise.resolve(this._data); } }}
)"
)
page.click("text=Add Filter")
f = page.query_selector("#filters .filter:last-child")
assert f
page.evaluate(
"arg => setSelectValue(arg.el.querySelector('.f-col'), arg.val)",
{"el": f, "val": "user"},
)
inp = f.query_selector(".f-val")
inp.click()
page.keyboard.type("alice")
page.keyboard.press("Enter")
page.keyboard.type("bob")
page.keyboard.press("Enter")
f.query_selector(".chip-copy").click()
assert page.evaluate("navigator.clipboard._data") == "alice,bob"
page.evaluate(
"var f=document.querySelector('#filters .filter:last-child'); f.chips=[]
; f.querySelectorAll('.chip').forEach(c=>c.remove())"
)
page.wait_for_selector("#filters .chip", state="detached")
inp.click()
page.evaluate(
"var dt=new DataTransfer(); dt.setData('text/plain','alice,bob'); var e=
new ClipboardEvent('paste',{clipboardData:dt}); document.querySelector('#filters
.filter:last-child .f-val').dispatchEvent(e);"
)
chips = page.evaluate(
"Array.from(document.querySelectorAll('#filters .filter:last-child .chip
')).map(c => c.firstChild.textContent)"
)
assert chips[:2] == ["alice", "bob"]
page.evaluate(
"var f=document.querySelector('#filters .filter:last-child'); f.chips=[]
; f.querySelectorAll('.chip').forEach(c=>c.remove())"
)
page.wait_for_selector("#filters .chip", state="detached")
inp.click()
page.evaluate(
"var dt=new DataTransfer(); dt.setData('text/plain','alice,bob'); var e=
new ClipboardEvent('paste',{clipboardData:dt}); Object.defineProperty(e,'shiftKe
y',{value:true}); document.querySelector('#filters .filter:last-child .f-val').d
ispatchEvent(e);"
)
chips = page.evaluate(
"Array.from(document.querySelectorAll('#filters .filter:last-child .chip
')).map(c => c.firstChild.textContent)"
)
assert chips[-1] == "alice,bob"
...
run_query(
page,
server_url,
start="2024-01-01 00:00:00",
end="2024-01-02 00:00:00",
order_by="timestamp",
limit=1,
)
cell = page.text_content("#results td")
assert cell != "Invalid Date"
valid = page.evaluate("v => !isNaN(Date.parse(v))", cell)
assert valid
def test_url_query_persistence(page: Any, server_url: str) -> None:
page.goto(server_url)
page.wait_for_selector("#order_by option", state="attached")
page.wait_for_function("window.lastResults !== undefined")
page.fill("#start", "2024-01-01 00:00:00")
page.fill("#end", "2024-01-02 00:00:00")
page.fill("#limit", "1")
page.evaluate("window.lastResults = undefined")
page.click("text=Dive")
page.wait_for_function("window.lastResults !== undefined")
first_url = page.url
first_rows = page.evaluate("window.lastResults.rows.length")
page.fill("#limit", "2")
page.evaluate("window.lastResults = undefined")
page.click("text=Dive")
page.wait_for_function("window.lastResults !== undefined")
second_url = page.url
second_rows = page.evaluate("window.lastResults.rows.length")
assert second_rows != first_rows
assert first_url != second_url
page.go_back()
page.wait_for_function("window.lastResults !== undefined")
assert page.url == first_url
assert page.evaluate("window.lastResults.rows.length") == first_rows
def test_load_from_url(page: Any, server_url: str) -> None:
url = (
f"{server_url}?start=2024-01-01%2000:00:00&end=2024-01-02%2000:00:00"
"&order_by=timestamp&limit=2"
)
page.goto(url)
page.wait_for_selector("#order_by option", state="attached")
page.wait_for_function("window.lastResults !== undefined")
assert page.input_value("#start") == "2024-01-01 00:00:00"
assert page.input_value("#end") == "2024-01-02 00:00:00"
assert page.input_value("#limit") == "2"
assert page.evaluate("window.lastResults.rows.length") == 2
def test_empty_data_message(page: Any, server_url: str) -> None:
data = run_query(
page,
server_url,
start="2025-01-01 00:00:00",
end="2025-01-02 00:00:00",
order_by="timestamp",
limit=100,
)
assert data["rows"] == []
msg = page.text_content("#view")
assert "Empty data provided to table" in msg
def test_group_by_chip_from_url(page: Any, server_url: str) -> None:
url = f"{server_url}?graph_type=table&group_by=user&order_by=user&limit=10"
page.goto(url)
page.wait_for_selector("#group_by_field .chip", state="attached")
chips = page.evaluate(
"Array.from(document.querySelectorAll('#group_by_field .chip')).map(c =>
c.firstChild.textContent)"
)
assert chips == ["user"]
def test_group_by_autocomplete(page: Any, server_url: str) -> None:
page.goto(f"{server_url}?graph_type=table")
page.wait_for_selector("#group_by_field", state="visible")
inp = page.query_selector("#group_by_field .f-val")
assert inp
inp.click()
page.keyboard.type("us")
page.wait_for_selector("#group_by_field .chip-dropdown div")
options = page.locator("#group_by_field .chip-dropdown div").all_inner_texts
()
assert "user" in options
def test_group_by_copy_icon(page: Any, server_url: str) -> None:
page.goto(f"{server_url}?graph_type=table")
page.wait_for_selector("#group_by_field", state="visible")
icon = page.text_content("#group_by_field .chip-copy")
assert icon == "⎘"
def test_group_by_input_no_border(page: Any, server_url: str) -> None:
page.goto(f"{server_url}?graph_type=table")
page.wait_for_selector("#group_by_field", state="visible")
border = page.evaluate(
"getComputedStyle(document.querySelector('#group_by_field .f-val')).bord
erStyle"
)
assert border == "none"
def test_table_group_by_query(page: Any, server_url: str) -> None:
data = run_query(
page,
server_url,
start="2024-01-01 00:00:00",
end="2024-01-03 00:00:00",
order_by="timestamp",
limit=100,
group_by=["user"],
aggregate="Count",
)
assert "error" not in data
assert len(data["rows"]) == 3
I'll scroll further to check the remaining tests toward the end.
root@947ba2ae34e4:/workspace/scubaduck# sed -n '640,960p' tests/test_web.py
I'll check the file length to confirm where it was truncated.
root@947ba2ae34e4:/workspace/scubaduck# wc -l tests/test_web.py
620 tests/test_web.py
I need to add a test for a table with group-by empty and aggregate function.
root@947ba2ae34e4:/workspace/scubaduck# ls scubaduck
__init__.py sample.csv server.py static
Going to open the server.py file now. Let's check what's inside!
root@947ba2ae34e4:/workspace/scubaduck# sed -n '1,200p' scubaduck/server.py
from __future__ import annotations
from dataclasses import dataclass, field
from typing import Any, Dict, List, Tuple
import re
from datetime import datetime, timedelta, timezone
import time
from pathlib import Path
import sqlite3
import traceback
import duckdb
from dateutil import parser as dtparser
from flask import Flask, jsonify, request, send_from_directory
@dataclass
class Filter:
column: str
op: str
value: str | int | float | list[str] | None
@dataclass
class QueryParams:
start: str | None = None
end: str | None = None
order_by: str | None = None
order_dir: str = "ASC"
limit: int | None = None
columns: list[str] = field(default_factory=lambda: [])
filters: list[Filter] = field(default_factory=lambda: [])
derived_columns: dict[str, str] = field(default_factory=lambda: {})
graph_type: str = "samples"
group_by: list[str] = field(default_factory=lambda: [])
aggregate: str | None = None
show_hits: bool = False
def _load_database(path: Path) -> duckdb.DuckDBPyConnection:
ext = path.suffix.lower()
if ext == ".csv":
con = duckdb.connect()
con.execute(
f"CREATE TABLE events AS SELECT * FROM read_csv_auto('{path.as_posix
()}')"
)
elif ext in {".db", ".sqlite"}:
con = duckdb.connect()
sconn = sqlite3.connect(path)
info = sconn.execute("PRAGMA table_info(events)").fetchall()
col_defs = ", ".join(f"{r[1]} {r[2]}" for r in info)
con.execute(f"CREATE TABLE events ({col_defs})")
placeholders = ",".join("?" for _ in info)
for row in sconn.execute("SELECT * FROM events"):
con.execute(f"INSERT INTO events VALUES ({placeholders})", row)
sconn.close()
else:
con = duckdb.connect(path)
return con
_REL_RE = re.compile(
r"([+-]?\d+(?:\.\d*)?)\s*(hour|hours|day|days|week|weeks|fortnight|fortnight
s)",
re.IGNORECASE,
)
def parse_time(val: str | None) -> str | None:
"""Parse an absolute or relative time string into ``YYYY-MM-DD HH:MM:SS``.""
"
if val is None or val == "":
return None
s = val.strip()
if s.lower() == "now":
dt = datetime.now(timezone.utc)
return dt.replace(microsecond=0).strftime("%Y-%m-%d %H:%M:%S")
m = _REL_RE.fullmatch(s)
if m:
qty = float(m.group(1))
unit = m.group(2).lower()
delta: timedelta
if unit.startswith("hour"):
delta = timedelta(hours=qty)
elif unit.startswith("day"):
delta = timedelta(days=qty)
elif unit.startswith("week"):
delta = timedelta(weeks=qty)
elif unit.startswith("fortnight"):
delta = timedelta(weeks=2 * qty)
else: # pragma: no cover - defensive
raise ValueError(f"Unsupported unit: {unit}")
dt = datetime.now(timezone.utc) + delta
return dt.replace(microsecond=0).strftime("%Y-%m-%d %H:%M:%S")
dt = dtparser.parse(s)
return dt.replace(microsecond=0, tzinfo=None).strftime("%Y-%m-%d %H:%M:%S")
def build_query(params: QueryParams) -> str:
select_parts: list[str] = []
if params.group_by:
select_parts.extend(params.group_by)
agg = (params.aggregate or "avg").lower()
def agg_expr(col: str) -> str:
if agg.startswith("p"):
quant = float(agg[1:]) / 100
return f"quantile({col}, {quant})"
if agg == "count distinct":
return f"count(DISTINCT {col})"
return f"{agg}({col})"
for col in params.columns:
if col in params.group_by:
continue
select_parts.append(f"{agg_expr(col)} AS {col}")
if params.show_hits:
select_parts.insert(len(params.group_by), "count(*) AS Hits")
else:
select_parts.extend(params.columns)
for name, expr in params.derived_columns.items():
select_parts.append(f"{expr} AS {name}")
select_clause = ", ".join(select_parts) if select_parts else "*"
query = f"SELECT {select_clause} FROM events"
where_parts: list[str] = []
if params.start:
where_parts.append(f"timestamp >= '{params.start}'")
if params.end:
where_parts.append(f"timestamp <= '{params.end}'")
for f in params.filters:
op = f.op
if op in {"empty", "!empty"}:
val = "''"
else:
if f.value is None:
continue
if isinstance(f.value, list):
if not f.value:
continue
if op == "=":
vals = " OR ".join(f"{f.column} = '{v}'" for v in f.value)
where_parts.append(f"({vals})")
continue
val = f"'{f.value}'" if isinstance(f.value, str) else str(f.value)
if op == "contains":
where_parts.append(f"{f.column} ILIKE '%' || {val} || '%'")
elif op == "!contains":
where_parts.append(f"{f.column} NOT ILIKE '%' || {val} || '%'")
elif op == "empty":
where_parts.append(f"{f.column} = {val}")
elif op == "!empty":
where_parts.append(f"{f.column} != {val}")
else:
where_parts.append(f"{f.column} {op} {val}")
if where_parts:
query += " WHERE " + " AND ".join(where_parts)
if params.group_by:
query += " GROUP BY " + ", ".join(params.group_by)
if params.order_by:
query += f" ORDER BY {params.order_by} {params.order_dir}"
if params.limit is not None:
query += f" LIMIT {params.limit}"
return query
def create_app(db_file: str | Path | None = None) -> Flask:
app = Flask(__name__, static_folder="static")
db_path = Path(db_file or Path(__file__).with_name("sample.csv")).resolve()
con = _load_database(db_path)
column_types: Dict[str, str] = {
r[1]: r[2] for r in con.execute("PRAGMA table_info(events)").fetchall()
}
sample_cache: Dict[Tuple[str, str], Tuple[List[str], float]] = {}
CACHE_TTL = 60.0
CACHE_LIMIT = 200
@app.route("/")
def index() -> Any: # pyright: ignore[reportUnusedFunction]
assert app.static_folder is not None
return send_from_directory(app.static_folder, "index.html")
@app.route("/api/columns")
def columns() -> Any: # pyright: ignore[reportUnusedFunction]
rows = con.execute("PRAGMA table_info(events)").fetchall()
return jsonify([{"name": r[1], "type": r[2]} for r in rows])
def _cache_get(key: Tuple[str, str]) -> List[str] | None:
item = sample_cache.get(key)
if item is None:
return None
vals, ts = item
if time.time() - ts > CACHE_TTL:
del sample_cache[key]
return None
sample_cache[key] = (vals, time.time())
return vals
I need to keep scrolling until I reach the relevant section for this task.
root@947ba2ae34e4:/workspace/scubaduck# sed -n '200,400p' scubaduck/server.py
return vals
def _cache_set(key: Tuple[str, str], vals: List[str]) -> None:
sample_cache[key] = (vals, time.time())
if len(sample_cache) > CACHE_LIMIT:
oldest = min(sample_cache.items(), key=lambda kv: kv[1][1])[0]
del sample_cache[oldest]
@app.route("/api/samples")
def sample_values() -> Any: # pyright: ignore[reportUnusedFunction]
column = request.args.get("column")
substr = request.args.get("q", "")
if not column or column not in column_types:
return jsonify([])
ctype = column_types[column].upper()
if "CHAR" not in ctype and "STRING" not in ctype and "VARCHAR" not in ct
ype:
return jsonify([])
key = (column, substr)
cached = _cache_get(key)
if cached is not None:
return jsonify(cached)
rows = con.execute(
f"SELECT DISTINCT {column} FROM events WHERE CAST({column} AS VARCHA
R) ILIKE '%' || ? || '%' LIMIT 20",
[substr],
).fetchall()
values = [r[0] for r in rows]
_cache_set(key, values)
return jsonify(values)
@app.route("/api/query", methods=["POST"])
def query() -> Any: # pyright: ignore[reportUnusedFunction]
payload = request.get_json(force=True)
try:
start = parse_time(payload.get("start"))
end = parse_time(payload.get("end"))
except Exception as exc:
return jsonify({"error": str(exc)}), 400
params = QueryParams(
start=start,
end=end,
order_by=payload.get("order_by"),
order_dir=payload.get("order_dir", "ASC"),
limit=payload.get("limit"),
columns=payload.get("columns", []),
derived_columns=payload.get("derived_columns", {}),
graph_type=payload.get("graph_type", "samples"),
group_by=payload.get("group_by", []),
aggregate=payload.get("aggregate"),
show_hits=payload.get("show_hits", False),
)
for f in payload.get("filters", []):
params.filters.append(Filter(f["column"], f["op"], f.get("value")))
if params.graph_type != "table" and (
params.group_by or params.aggregate or params.show_hits
):
return (
jsonify(
{
"error": "group_by, aggregate and show_hits are only val
id for table view"
}
),
400,
)
valid_cols = set(column_types.keys())
for col in params.columns:
if col not in valid_cols:
return jsonify({"error": f"Unknown column: {col}"}), 400
for col in params.group_by:
if col not in valid_cols:
return jsonify({"error": f"Unknown column: {col}"}), 400
if params.order_by and params.order_by not in valid_cols:
return jsonify({"error": f"Unknown column: {params.order_by}"}), 400
if params.group_by:
agg = (params.aggregate or "avg").lower()
if agg.startswith("p") or agg in {"avg", "sum"}:
need_numeric = True
allow_time = False
elif agg in {"min", "max"}:
need_numeric = False
allow_time = True
else:
need_numeric = False
allow_time = False
if need_numeric or allow_time:
for c in params.columns:
if c in params.group_by:
continue
ctype = column_types.get(c, "").upper()
is_numeric = any(
t in ctype
for t in [
"INT",
"DECIMAL",
"REAL",
"DOUBLE",
"FLOAT",
"NUMERIC",
"HUGEINT",
]
)
is_time = "TIMESTAMP" in ctype or "DATE" in ctype or "TIME"
in ctype
if need_numeric and not is_numeric:
return (
jsonify(
{
"error": f"Aggregate {agg} cannot be applied
to column {c}",
}
),
400,
)
if allow_time and not (is_numeric or is_time):
return (
jsonify(
{
"error": f"Aggregate {agg} cannot be applied
to column {c}",
}
),
400,
)
sql = build_query(params)
try:
rows = con.execute(sql).fetchall()
except Exception as exc:
tb = traceback.format_exc()
print(f"Query failed:\n{sql}\n{tb}")
return (
jsonify({"sql": sql, "error": str(exc), "traceback": tb}),
400,
)
return jsonify({"sql": sql, "rows": rows})
return app
app = create_app()
if __name__ == "__main__":
app.run(debug=True)
I see some logic issues in group_by and aggregate, especially with AVG on timestamptz.
root@947ba2ae34e4:/workspace/scubaduck# head -n 10 scubaduck/sample.csv
timestamp,event,value,user
2024-01-01 00:00:00,login,10,alice
2024-01-01 01:00:00,logout,20,bob
2024-01-02 00:00:00,login,30,alice
2024-01-02 03:00:00,login,40,charlie
I'll go ahead and take a look at the front-end static files now.
root@947ba2ae34e4:/workspace/scubaduck# ls scubaduck/static
index.html
I'll take a look at index.html to check out its contents.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>ScubaDuck</title>
<style>
body { margin: 0; font-family: sans-serif; height: 100vh; display: flex; fle
x-direction: column; }
#header { padding: 10px; font-weight: bold; border-bottom: 1px solid #ccc; }
#content { flex: 1; display: flex; height: calc(100vh - 42px); overflow: hid
den; }
#sidebar { width: 450px; padding: 10px; border-right: 3px solid #ccc; overfl
ow-y: auto; display: flex; flex-direction: column; box-sizing: border-box; }
#sidebar-resizer { width: 5px; cursor: col-resize; background: #ccc; }
#view { flex: 1; padding: 10px; overflow-y: auto; overflow-x: auto; }
.field { display: flex; align-items: center; margin-bottom: 10px; }
.field label { width: 80px; text-align: right; margin-right: 5px; }
.help { margin-left: 4px; cursor: help; }
.rel-btn { margin-left: 4px; }
#tabs { display: flex; align-items: center; margin-bottom: 10px; }
#tabs .tab { margin-right: 5px; background: none; border: 1px solid #ccc; pa
dding: 4px 8px; cursor: pointer; width: 120px; text-align: center; box-sizing: b
order-box; }
#tabs .tab.active { background: #eee; font-weight: bold; }
#dive { margin-left: auto; background: green; color: white; border: none; pa
dding: 5px 10px; cursor: pointer; }
.tab-content { display: none; }
.tab-content.active { display: block; }
#filter_list { display: flex; flex-direction: column; }
#filters .filter {
border: 1px solid #ccc;
padding: 5px;
margin-bottom: 5px;
position: relative;
display: flex;
flex-direction: column;
}
#filters .filter-row { display: flex; margin-bottom: 5px; }
#filters .filter-row .f-col { flex: 1; }
#filters .filter-row .f-op {
margin-left: 5px;
width: fit-content;
flex: 0 0 auto;
}
.chip-input input {
border: none;
flex: 1;
min-width: 60px;
margin: 2px;
outline: none;
}
.chip-box { position: relative; }
.chip-input { display: flex; flex-wrap: wrap; border: 1px solid #ccc; paddin
g: 2px; min-height: 24px; }
.chip { background: #eee; border: 1px solid #999; padding: 2px 4px; margin:
2px; border-radius: 3px; display: flex; align-items: center; }
.chip .x { margin-left: 4px; cursor: pointer; }
.chip-copy { margin-left: 4px; cursor: pointer; background: none; border: no
ne; }
.chip-dropdown { position: absolute; left: 0; right: 0; top: 100%; backgroun
d: white; border: 1px solid #ccc; max-height: 120px; overflow-y: auto; z-index:
10; display: none; }
.chip-dropdown div { padding: 2px 4px; cursor: pointer; }
.chip-dropdown div.highlight { background: #bde4ff; }
.rel-box { position: relative; display: flex; }
.rel-dropdown { position: absolute; left: 0; right: 0; top: 100%; background
: white; border: 1px solid #ccc; z-index: 10; display: none; }
.rel-dropdown div { padding: 2px 4px; cursor: pointer; }
.rel-dropdown div:hover { background: #bde4ff; }
.dropdown { position: relative; display: inline-block; }
.dropdown-display { border: 1px solid #ccc; padding: 2px 18px 2px 4px; curso
r: pointer; min-width: 80px; }
.dropdown-menu { position: absolute; left: 0; right: 0; top: 100%; backgroun
d: white; border: 1px solid #ccc; z-index: 10; max-height: 160px; overflow-y: au
to; display: none; }
.dropdown-menu input { width: 100%; box-sizing: border-box; padding: 2px 4px
; border: none; border-bottom: 1px solid #ccc; }
.dropdown-menu div { padding: 2px 4px; cursor: pointer; }
.dropdown-menu div.selected { background: #bde4ff; }
.dropdown-menu div:hover { background: #eee; }
#filters .filter button.remove {
margin-left: 5px;
width: 20px;
flex: 0 0 auto;
}
#filters h4 { margin: 0 0 5px 0; }
table { border-collapse: collapse; min-width: 100%; }
th, td { border: 1px solid #ccc; padding: 4px; box-sizing: border-box; }
th { text-align: left; cursor: pointer; position: relative; }
th.sorted { color: blue; }
tr:nth-child(even) td { background: #f9f9f9; }
tr.selected td { background: #bde4ff !important; }
tr:hover:not(.selected) td { background: #eee; }
#column_actions {
text-align: right;
margin-bottom: 5px;
}
#column_actions a {
margin-left: 5px;
}
.col-group-header {
overflow: hidden;
}
.col-group-header .links {
float: right;
}
.col-group-header .links a {
margin-left: 5px;
}
/* Column resizer removed */
</style>
</head>
<body>
<div id="header">sample.csv - events <select id="graph_type"><option value="sa
mples">Samples</option><option value="table">Table</option></select></div>
<div id="content">
<div id="sidebar">
<div id="tabs">
<button class="tab active" data-tab="settings">View Settings</button>
<button class="tab" data-tab="columns">Columns</button>
<button id="dive" onclick="dive()">Dive</button>
</div>
<div id="settings" class="tab-content active">
<div class="field">
<label>Start<span class="help" title="Sets the start/end of the time r
ange to query. Can be any kind of datetime string. For example: 'April 23, 2014'
or 'yesterday'.">[?]</span></label>
<div class="rel-box">
<input id="start" type="text" />
<button type="button" class="rel-btn" data-target="start-select">	
660;</button>
<div id="start-select" class="rel-dropdown" data-input="start">
<div data-value="-1 hour">-1 hour</div>
<div data-value="-3 hours">-3 hours</div>
<div data-value="-12 hours">-12 hours</div>
<div data-value="-1 day">-1 day</div>
<div data-value="-3 days">-3 days</div>
<div data-value="-1 week">-1 week</div>
<div data-value="-1 fortnight">-1 fortnight</div>
<div data-value="-30 days">-30 days</div>
<div data-value="-90 days">-90 days</div>
</div>
</div>
</div>
<div class="field">
<label>End<span class="help" title="Sets the start/end of the time ran
ge to query. Can be any kind of datetime string. For example: 'April 23, 2014' o
r 'yesterday'.">[?]</span></label>
<div class="rel-box">
<input id="end" type="text" />
<button type="button" class="rel-btn" data-target="end-select">φ
0;</button>
<div id="end-select" class="rel-dropdown" data-input="end">
<div data-value="now">now</div>
<div data-value="-1 hour">-1 hour</div>
<div data-value="-3 hours">-3 hours</div>
<div data-value="-12 hours">-12 hours</div>
<div data-value="-1 day">-1 day</div>
<div data-value="-3 days">-3 days</div>
<div data-value="-1 week">-1 week</div>
<div data-value="-1 fortnight">-1 fortnight</div>
<div data-value="-30 days">-30 days</div>
<div data-value="-90 days">-90 days</div>
</div>
</div>
</div>
<div class="field">
<label>Order By<span class="help" title="Choose a column to sort resul
ts by.">[?]</span></label>
<select id="order_by"></select>
<button id="order_dir" type="button">ASC \u25B2</button>
</div>
<div class="field">
<label>Limit<span class="help" title="Choose the maximum number of res
ults to show in the chart after any aggregations have been applied. For example,
a limit of 10 will show no more than 10 rows for a table, etc.">[?]</span></lab
el>
<input id="limit" type="number" value="100" />
</div>
<div id="group_by_field" class="field" style="display:none;">
<label>Group By</label>
<div class="chip-box">
<div class="chip-input">
<input id="group_by" class="f-val" type="text">
<button type="button" class="chip-copy">⎘</button>
</div>
<div class="chip-dropdown"></div>
</div>
</div>
<div id="aggregate_field" class="field" style="display:none;">
<label>Aggregate</label>
<select id="aggregate">
<option>Avg</option>
<option>Count</option>
<option>Sum</option>
<option>Min</option>
<option>Max</option>
<option>Count Distinct</option>
<option>p5</option>
<option>p25</option>
<option>p50</option>
<option>p70</option>
<option>p75</option>
<option>p90</option>
<option>p95</option>
<option>p99</option>
<option>p99.9</option>
<option>p99.99</option>
</select>
</div>
<div id="show_hits_field" class="field" style="display:none;">
<label>Show Hits</label>
<input id="show_hits" type="checkbox" checked>
</div>
<div id="filters">
<h4>Filters<span class="help" title="You can create as many filters as
you want. You can either write a filter using a UI or manual SQL. In the UI, fi
lter consists of a column name, a relation (e.g., =, !=, <, >) and then a text f
ield. The text field is a token input. It accepts multiple tokens for = relation
, in which case we match using an OR for all options.">[?]</span></h4>
<div id="filter_list"></div>
<button id="add_filter" type="button" onclick="addFilter()">Add Filter
</button>
</div>
<div id="query_info" style="margin-top:10px;"></div>
</div>
<div id="columns" class="tab-content">
<div id="column_actions">
<a id="columns_all" href="#">All</a>
<a id="columns_none" href="#">None</a>
</div>
<div id="column_groups"></div>
I'm continuing down the page to explore more scripts.
root@947ba2ae34e4:/workspace/scubaduck# sed -n '200,400p' scubaduck/static/index
.html
<div id="column_groups"></div>
</div>
</div>
<div id="sidebar-resizer"></div>
<div id="view">
<table id="results"></table>
</div>
</div>
<script>
const allColumns = [];
const columnTypes = {};
const stringColumns = [];
const integerColumns = [];
const timeColumns = [];
let selectedColumns = [];
let displayType = 'samples';
let groupBy = {chips: [], addChip: () => {}, renderChips: () => {}};
function initDropdown(select) {
const wrapper = document.createElement('div');
wrapper.className = 'dropdown';
select.parentNode.insertBefore(wrapper, select);
wrapper.appendChild(select);
select.style.display = 'none';
const disp = document.createElement('div');
disp.className = 'dropdown-display';
function updateDisplay() {
const opt = select.options[select.selectedIndex];
disp.textContent = opt ? opt.textContent : '';
}
updateDisplay();
wrapper.appendChild(disp);
const menu = document.createElement('div');
menu.className = 'dropdown-menu';
const search = document.createElement('input');
menu.appendChild(search);
const list = document.createElement('div');
menu.appendChild(list);
wrapper.appendChild(menu);
function close() {
menu.style.display = 'none';
}
function open() {
renderOptions();
menu.style.display = 'block';
search.focus();
}
disp.addEventListener('click', () => {
if (menu.style.display === 'block') {
close();
} else {
open();
}
});
document.addEventListener('click', e => {
if (!wrapper.contains(e.target)) {
close();
}
});
function renderOptions() {
const q = search.value.toLowerCase();
list.innerHTML = '';
Array.from(select.options).forEach(o => {
if (!o.textContent.toLowerCase().includes(q)) return;
const div = document.createElement('div');
div.textContent = o.textContent;
if (o.value === select.value) div.className = 'selected';
div.addEventListener('mousedown', evt => {
evt.preventDefault();
select.value = o.value;
select.dispatchEvent(new Event('change'));
updateDisplay();
close();
});
list.appendChild(div);
});
}
search.addEventListener('input', renderOptions);
select.addEventListener('change', updateDisplay);
}
// Sidebar resizing
const sidebar = document.getElementById('sidebar');
const sidebarResizer = document.getElementById('sidebar-resizer');
let sidebarWidth = parseInt(localStorage.getItem('sidebarWidth') || 450, 10);
sidebar.style.width = sidebarWidth + 'px';
let sidebarResize = false;
function startSidebarDrag(e) {
e.preventDefault();
sidebarResize = true;
document.addEventListener('mousemove', onSidebarDrag);
document.addEventListener('mouseup', stopSidebarDrag);
}
function onSidebarDrag(e) {
if (!sidebarResize) return;
sidebarWidth = Math.max(200, e.clientX - sidebar.getBoundingClientRect().left)
;
sidebar.style.width = sidebarWidth + 'px';
}
function stopSidebarDrag() {
document.removeEventListener('mousemove', onSidebarDrag);
document.removeEventListener('mouseup', stopSidebarDrag);
sidebarResize = false;
localStorage.setItem('sidebarWidth', sidebarWidth);
}
sidebarResizer.addEventListener('mousedown', startSidebarDrag);
let orderDir = 'ASC';
const orderDirBtn = document.getElementById('order_dir');
const graphTypeSel = document.getElementById('graph_type');
function updateOrderDirButton() {
orderDirBtn.textContent = orderDir + (orderDir === 'ASC' ? ' \u25B2' : ' \u25B
C');
}
function updateDisplayTypeUI() {
const show = graphTypeSel.value === 'table';
document.getElementById('group_by_field').style.display = show ? 'flex' : 'non
e';
document.getElementById('aggregate_field').style.display = show ? 'flex' : 'no
ne';
document.getElementById('show_hits_field').style.display = show ? 'flex' : 'no
ne';
document.querySelectorAll('#column_groups .col-group').forEach(g => {
if (g.querySelector('.col-group-header').textContent.startsWith('Strings'))
{
g.style.display = show ? 'none' : '';
}
});
displayType = graphTypeSel.value;
}
orderDirBtn.addEventListener('click', () => {
orderDir = orderDir === 'ASC' ? 'DESC' : 'ASC';
updateOrderDirButton();
});
updateOrderDirButton();
graphTypeSel.addEventListener('change', updateDisplayTypeUI);
fetch('/api/columns').then(r => r.json()).then(cols => {
const orderSelect = document.getElementById('order_by');
const groupsEl = document.getElementById('column_groups');
const groups = {
time: {name: 'Time', cols: [], ul: null},
integer: {name: 'Integers', cols: [], ul: null},
string: {name: 'Strings', cols: [], ul: null}
};
cols.forEach(c => {
const t = c.type.toUpperCase();
columnTypes[c.name] = c.type;
allColumns.push(c.name);
let g = 'string';
if (t.includes('INT')) g = 'integer';
if (t.includes('TIMESTAMP')) g = 'time';
groups[g].cols.push(c.name);
if (g !== 'string') {
const o = document.createElement('option');
o.value = c.name;
o.textContent = c.name;
orderSelect.appendChild(o);
}
});
Object.keys(groups).forEach(key => {
const g = groups[key];
const div = document.createElement('div');
div.className = 'col-group';
const header = document.createElement('div');
header.className = 'col-group-header';
header.appendChild(document.createTextNode(g.name + ': '));
const links = document.createElement('span');
links.className = 'links';
const allBtn = document.createElement('a');
allBtn.href = '#';
allBtn.textContent = 'All';
const noneBtn = document.createElement('a');
noneBtn.href = '#';
noneBtn.textContent = 'None';
links.appendChild(allBtn);
links.appendChild(noneBtn);
header.appendChild(links);
div.appendChild(header);
const ul = document.createElement('ul');
g.ul = ul;
g.cols.forEach(name => {
const li = document.createElement('li');
const label = document.createElement('label');
const cb = document.createElement('input');
cb.type = 'checkbox';
cb.value = name;
cb.checked = true;
cb.addEventListener('change', updateSelectedColumns);
label.appendChild(cb);
label.appendChild(document.createTextNode(' ' + name));
li.appendChild(label);
ul.appendChild(li);
});
allBtn.addEventListener('click', e => {
e.preventDefault();
ul.querySelectorAll('input').forEach(cb => (cb.checked = true));
updateSelectedColumns();
});
noneBtn.addEventListener('click', e => {
e.preventDefault();
ul.querySelectorAll('input').forEach(cb => (cb.checked = false));
updateSelectedColumns();
root@947ba2ae34e4:/workspace/scubaduck# sed -n '400,800p' scubaduck/static/index
.html
updateSelectedColumns();
});
div.appendChild(ul);
groupsEl.appendChild(div);
});
document.getElementById('columns_all').addEventListener('click', e => {
e.preventDefault();
groupsEl.querySelectorAll('input').forEach(cb => (cb.checked = true));
updateSelectedColumns();
});
document.getElementById('columns_none').addEventListener('click', e => {
e.preventDefault();
groupsEl.querySelectorAll('input').forEach(cb => (cb.checked = false));
updateSelectedColumns();
});
updateSelectedColumns();
groupBy = document.getElementById('group_by').closest('.field');
initChipInput(groupBy, typed =>
allColumns.filter(c => c.toLowerCase().includes(typed.toLowerCase()))
);
initDropdown(orderSelect);
initDropdown(document.getElementById('aggregate'));
initDropdown(graphTypeSel);
updateDisplayTypeUI();
addFilter();
initFromUrl();
});
document.querySelectorAll('#tabs .tab').forEach(btn => {
btn.addEventListener('click', () => {
document.querySelectorAll('#tabs .tab').forEach(t => t.classList.remove('act
ive'));
document.querySelectorAll('.tab-content').forEach(c => c.classList.remove('a
ctive'));
btn.classList.add('active');
document.getElementById(btn.dataset.tab).classList.add('active');
});
});
document.querySelectorAll('.rel-btn').forEach(btn => {
btn.addEventListener('click', () => {
const dd = document.getElementById(btn.dataset.target);
const show = dd.style.display === 'none' || dd.style.display === '';
document.querySelectorAll('.rel-dropdown').forEach(d => (d.style.display = '
none'));
dd.style.display = show ? 'block' : 'none';
});
});
document.querySelectorAll('.rel-dropdown div').forEach(opt => {
opt.addEventListener('click', () => {
const box = opt.closest('.rel-box');
const input = box.querySelector('input');
input.value = opt.dataset.value || opt.textContent;
opt.parentElement.style.display = 'none';
});
});
document.addEventListener('click', e => {
document.querySelectorAll('.rel-dropdown').forEach(dd => {
if (!dd.parentElement.contains(e.target)) dd.style.display = 'none';
});
});
function updateSelectedColumns() {
const base = allColumns.filter(name => {
const cb = document.querySelector(`#column_groups input[value="${name}"]`);
if (!cb || !cb.checked) return false;
if (graphTypeSel.value === 'table' && isStringColumn(name)) return false;
return true;
});
if (graphTypeSel.value === 'table') {
selectedColumns = groupBy.chips.slice();
if (document.getElementById('show_hits').checked) selectedColumns.push('Hits
');
base.forEach(c => {
if (!selectedColumns.includes(c)) selectedColumns.push(c);
});
} else {
selectedColumns = base;
}
}
function isStringColumn(name) {
const t = (columnTypes[name] || '').toUpperCase();
return t.includes('CHAR') || t.includes('STRING') || t.includes('VARCHAR');
}
function isIntegerColumn(name) {
const t = (columnTypes[name] || '').toUpperCase();
return t.includes('INT');
}
function isTimeColumn(name) {
const t = (columnTypes[name] || '').toUpperCase();
return t.includes('TIMESTAMP');
}
function initChipInput(filter, fetchOptions) {
const input = filter.querySelector('.f-val');
const chipsEl = filter.querySelector('.chip-input');
const dropdown = filter.querySelector('.chip-dropdown');
const copyBtn = filter.querySelector('.chip-copy');
const chips = [];
filter.chips = chips;
filter.renderChips = renderChips;
filter.addChip = addChip;
let highlight = 0;
chipsEl.addEventListener('click', () => {
input.focus();
});
function renderChips() {
chipsEl.querySelectorAll('.chip').forEach(c => c.remove());
chips.forEach((v, i) => {
const span = document.createElement('span');
span.className = 'chip';
span.textContent = v;
const x = document.createElement('span');
x.className = 'x';
x.textContent = '✖';
x.addEventListener('click', () => {
chips.splice(i, 1);
...
['>', '>'],
];
opSel.innerHTML = ops.map(o => `<option value="${o[0]}">${o[1]}</option>`).j
oin('');
updateInputVis();
}
function updateInputVis() {
const op = container.querySelector('.f-op').value;
const box = container.querySelector('.chip-box');
box.style.display = op === 'empty' || op === '!empty' ? 'none' : 'block';
}
colSel.addEventListener('change', populateOps);
container.querySelector('.f-op').addEventListener('change', updateInputVis);
initDropdown(container.querySelector('.f-op'));
populateOps();
document.getElementById('filter_list').appendChild(container);
initChipInput(container, (typed, el) => {
const colSel = el.querySelector('.f-col');
if (!colSel) return [];
const col = colSel.value;
if (!isStringColumn(col)) return [];
return fetch(`/api/samples?column=${encodeURIComponent(col)}&q=${encodeURICo
mponent(typed)}`)
.then(r => r.json());
});
}
let lastQueryTime = 0;
let queryStart = 0;
function dive(push=true) {
const payload = collectParams();
if (push) {
history.pushState(payload, '', paramsToSearch(payload));
}
const view = document.getElementById('view');
view.innerHTML = '<p>Loading...</p>';
window.lastResults = undefined;
queryStart = performance.now();
fetch('/api/query', {method:'POST', headers:{'Content-Type':'application/json'
}, body:JSON.stringify(payload)})
.then(async r => {
const data = await r.json();
if (!r.ok) throw data;
return data;
})
.then(data => {
lastQueryTime = Math.round(performance.now() - queryStart);
showResults(data);
})
.catch(err => {
showError(err);
});
}
function collectParams() {
updateSelectedColumns();
const payload = {
start: document.getElementById('start').value,
end: document.getElementById('end').value,
order_by: document.getElementById('order_by').value,
order_dir: orderDir,
limit: parseInt(document.getElementById('limit').value, 10),
columns: selectedColumns.filter(c => c !== 'Hits'),
graph_type: graphTypeSel.value,
filters: Array.from(document.querySelectorAll('#filters .filter')).map(f =>
{
const chips = f.chips || [];
const op = f.querySelector('.f-op').value;
let value = null;
if (op !== 'empty' && op !== '!empty') {
value = chips.length === 0 ? null : (chips.length === 1 ? chips[0] : chi
ps);
}
return {column: f.querySelector('.f-col').value, op, value};
})
};
if (graphTypeSel.value === 'table') {
payload.group_by = groupBy.chips || [];
payload.aggregate = document.getElementById('aggregate').value;
payload.show_hits = document.getElementById('show_hits').checked;
}
return payload;
}
function paramsToSearch(params) {
const sp = new URLSearchParams();
if (params.start) sp.set('start', params.start);
if (params.end) sp.set('end', params.end);
if (params.order_by) sp.set('order_by', params.order_by);
if (params.order_dir) sp.set('order_dir', params.order_dir);
if (params.limit !== null && params.limit !== undefined) sp.set('limit', param
s.limit);
if (params.columns && params.columns.length) sp.set('columns', params.columns.
join(','));
if (params.filters && params.filters.length) sp.set('filters', JSON.stringify(
params.filters));
if (params.graph_type) sp.set('graph_type', params.graph_type);
if (params.graph_type === 'table') {
if (params.group_by && params.group_by.length) sp.set('group_by', params.gro
up_by.join(','));
if (params.aggregate) sp.set('aggregate', params.aggregate);
if (params.show_hits) sp.set('show_hits', '1');
}
const qs = sp.toString();
return qs ? '?' + qs : '';
}
function applyParams(params) {
document.getElementById('start').value = params.start || '';
document.getElementById('end').value = params.end || '';
if (params.order_by) {
document.getElementById('order_by').value = params.order_by;
}
orderDir = params.order_dir || 'ASC';
updateOrderDirButton();
if (params.limit !== undefined && params.limit !== null) {
document.getElementById('limit').value = params.limit;
}
graphTypeSel.value = params.graph_type || 'samples';
updateDisplayTypeUI();
if (params.group_by) {
I need to continue to the part that shows the results as a table.
root@947ba2ae34e4:/workspace/scubaduck# sed -n '800,1200p' scubaduck/static/inde
x.html
if (params.group_by) {
groupBy.chips.splice(0, groupBy.chips.length, ...params.group_by);
groupBy.renderChips();
}
if (params.aggregate) document.getElementById('aggregate').value = params.aggr
egate;
document.getElementById('show_hits').checked = params.show_hits ?? true;
document.querySelectorAll('#column_groups input').forEach(cb => {
cb.checked = !params.columns || params.columns.includes(cb.value);
});
updateSelectedColumns();
const list = document.getElementById('filter_list');
list.innerHTML = '';
if (params.filters && params.filters.length) {
params.filters.forEach(f => {
addFilter();
const el = list.lastElementChild;
el.querySelector('.f-col').value = f.column;
el.querySelector('.f-col').dispatchEvent(new Event('change'));
el.querySelector('.f-op').value = f.op;
el.querySelector('.f-op').dispatchEvent(new Event('change'));
if (f.value !== null && f.op !== 'empty' && f.op !== '!empty') {
const values = Array.isArray(f.value) ? f.value : [f.value];
values.forEach(v => el.addChip(v));
el.renderChips();
}
});
} else {
addFilter();
}
}
function parseSearch() {
const sp = new URLSearchParams(window.location.search);
const params = {};
if (sp.has('start')) params.start = sp.get('start');
if (sp.has('end')) params.end = sp.get('end');
if (sp.has('order_by')) params.order_by = sp.get('order_by');
if (sp.has('order_dir')) params.order_dir = sp.get('order_dir');
if (sp.has('limit')) params.limit = parseInt(sp.get('limit'), 10);
if (sp.has('columns')) params.columns = sp.get('columns').split(',').filter(c
=> c);
if (sp.has('filters')) {
try { params.filters = JSON.parse(sp.get('filters')); } catch(e) { params.fi
lters = []; }
}
if (sp.has('graph_type')) params.graph_type = sp.get('graph_type');
if (sp.has('group_by')) params.group_by = sp.get('group_by').split(',').filter
(c => c);
if (sp.has('aggregate')) params.aggregate = sp.get('aggregate');
if (sp.has('show_hits')) params.show_hits = sp.get('show_hits') === '1';
return params;
}
function initFromUrl() {
const params = parseSearch();
history.replaceState(params, '', paramsToSearch(params));
applyParams(params);
dive(false);
}
window.addEventListener('popstate', e => {
const params = e.state || parseSearch();
applyParams(params);
dive(false);
});
let originalRows = [];
let sortState = {index: null, dir: null};
function renderTable(rows) {
const table = document.getElementById('results');
table.innerHTML = '';
if (rows.length === 0) return;
let hitsIndex = selectedColumns.indexOf('Hits');
let totalHits = 0;
if (hitsIndex !== -1) {
totalHits = rows.reduce((s, r) => s + Number(r[hitsIndex]), 0);
}
const header = document.createElement('tr');
selectedColumns.forEach((col, i) => {
const th = document.createElement('th');
th.textContent = col;
th.dataset.index = i;
th.addEventListener('click', handleSort);
if (sortState.index === i) {
th.classList.add('sorted');
th.textContent = col + (sortState.dir === 'desc' ? ' \u25BC' : ' \u25B2');
}
if (!isStringColumn(col)) th.style.textAlign = 'right';
header.appendChild(th);
});
table.appendChild(header);
rows.forEach(row => {
const tr = document.createElement('tr');
tr.addEventListener('click', () => {
tr.classList.toggle('selected');
});
row.forEach((v, i) => {
const col = selectedColumns[i];
const td = document.createElement('td');
if (isTimeColumn(col)) {
const d = new Date(v);
td.textContent = d.toLocaleString('en-US', {
weekday: 'short',
month: 'short',
day: 'numeric',
year: 'numeric',
hour: 'numeric',
minute: 'numeric',
second: 'numeric',
hour12: true,
timeZoneName: 'short'
});
} else {
if (col === 'Hits') {
const pct = totalHits ? ((v / totalHits) * 100).toFixed(1) : '0';
td.textContent = `${v} (${pct}%)`;
} else {
td.textContent = v;
}
}
td.style.textAlign = isStringColumn(col) ? 'left' : 'right';
tr.appendChild(td);
});
table.appendChild(tr);
});
// ensure table does not overflow unless necessary
const view = document.getElementById('view');
if (table.scrollWidth <= view.clientWidth) {
table.style.width = '100%';
}
}
function handleSort(e) {
const idx = parseInt(e.target.dataset.index, 10);
if (sortState.index !== idx) {
sortState.index = idx;
sortState.dir = 'asc';
} else if (sortState.dir === 'asc') {
sortState.dir = 'desc';
} else if (sortState.dir === 'desc') {
sortState.index = null;
sortState.dir = null;
} else {
sortState.dir = 'asc';
}
let rows = originalRows.slice();
if (sortState.index !== null) {
rows.sort((a, b) => {
const va = a[sortState.index];
const vb = b[sortState.index];
if (va === vb) return 0;
if (sortState.dir === 'desc') return va < vb ? 1 : -1;
return va > vb ? 1 : -1;
});
}
renderTable(rows);
}
function showResults(data) {
window.lastResults = data;
const view = document.getElementById('view');
if (data.rows.length === 0) {
view.innerHTML =
'<p id="empty-message">Empty data provided to table</p><table id="results"
></table>';
} else {
view.innerHTML = '<table id="results"></table>';
}
originalRows = data.rows.slice();
sortState = {index: null, dir: null};
renderTable(originalRows);
document.getElementById('query_info').textContent =
`Your query took about ${lastQueryTime} ms`;
}
function showError(err) {
window.lastResults = err;
const view = document.getElementById('view');
let msg = '';
if (typeof err === 'string') {
msg = err;
} else if (err) {
msg = err.error || 'Error';
if (err.sql) {
msg += '\nSQL: ' + err.sql;
}
if (err.traceback) {
msg += '\n' + err.traceback;
}
}
view.innerHTML = `<pre id="error-message">${msg}</pre>`;
document.getElementById('query_info').textContent = '';
}
function setSelectValue(selector, value) {
const el = typeof selector === 'string' ? document.querySelector(selector) : s
elector;
if (el) {
el.value = value;
el.dispatchEvent(new Event('change'));
}
}
</script>
</body>
</html>
I’ll create a test that mimics user interaction and verifies the table functionality issue.
from scubaduck import server
import pytest
def test_basic_query() -> None:
app = server.app
client = app.test_client()
payload = {
"start": "2024-01-01 00:00:00",
"end": "2024-01-02 00:00:00",
"order_by": "timestamp",
"order_dir": "ASC",
"limit": 10,
"columns": ["timestamp", "event", "value", "user"],
"filters": [],
}
rv = client.post(
"/api/query", data=json.dumps(payload), content_type="application/json"
)
data = rv.get_json()
assert data
rows = data["rows"]
# We expect first three rows (until 2024-01-02 00:00:00)
assert len(rows) == 3
assert rows[0][1] == "login"
assert rows[1][1] == "logout"
def test_filter_multi_token() -> None:
app = server.app
client = app.test_client()
payload = {
"start": "2024-01-01 00:00:00",
"end": "2024-01-02 03:00:00",
"order_by": "timestamp",
"limit": 10,
"columns": ["timestamp", "event", "value", "user"],
"filters": [{"column": "user", "op": "=", "value": ["alice", "charlie"]}
],
}
rv = client.post(
"/api/query", data=json.dumps(payload), content_type="application/json"
)
data = rv.get_json()
assert data
rows = data["rows"]
# Should only return rows for alice and charlie
assert len(rows) == 3
assert rows[0][3] == "alice"
assert rows[-1][3] == "charlie"
def test_empty_filter_is_noop() -> None:
app = server.app
client = app.test_client()
base_payload = {
"start": "2024-01-01 00:00:00",
"end": "2024-01-03 00:00:00",
"order_by": "timestamp",
"limit": 100,
"columns": ["timestamp", "event", "value", "user"],
}
no_filter = {**base_payload, "filters": []}
empty_filter = {
**base_payload,
"filters": [{"column": "user", "op": "=", "value": None}],
}
rv1 = client.post(
"/api/query", data=json.dumps(no_filter), content_type="application/json
"
)
rv2 = client.post(
"/api/query", data=json.dumps(empty_filter), content_type="application/j
son"
)
rows1 = rv1.get_json()["rows"]
rows2 = rv2.get_json()["rows"]
assert rows1 == rows2
def test_select_columns() -> None:
app = server.app
client = app.test_client()
payload = {
"start": "2024-01-01 00:00:00",
"end": "2024-01-03 00:00:00",
"order_by": "timestamp",
"limit": 10,
"columns": ["timestamp", "user"],
"filters": [],
}
rv = client.post(
"/api/query", data=json.dumps(payload), content_type="application/json"
)
data = rv.get_json()
assert data
rows = data["rows"]
assert len(rows[0]) == 2
assert rows[0][1] == "alice"
def test_string_filter_ops() -> None:
app = server.app
client = app.test_client()
base = {
"start": "2024-01-01 00:00:00",
"end": "2024-01-03 00:00:00",
"order_by": "timestamp",
"limit": 100,
"columns": ["timestamp", "event", "value", "user"],
}
contains = {
**base,
"filters": [{"column": "user", "op": "contains", "value": "ali"}],
}
rv = client.post(
"/api/query", data=json.dumps(contains), content_type="application/json"
)
rows = rv.get_json()["rows"]
assert all("ali" in r[3] for r in rows)
regex = {
**base,
"filters": [{"column": "user", "op": "~", "value": "^a.*"}],
}
rv = client.post(
"/api/query", data=json.dumps(regex), content_type="application/json"
)
rows = rv.get_json()["rows"]
assert all(r[3].startswith("a") for r in rows)
assert len(rows) == 2
not_empty = {**base, "filters": [{"column": "user", "op": "!empty"}]}
rv = client.post(
"/api/query", data=json.dumps(not_empty), content_type="application/json
"
)
assert len(rv.get_json()["rows"]) == 4
def _make_payload() -> dict[str, object]:
return {
"start": "2024-01-01 00:00:00",
"end": "2024-01-02 00:00:00",
"order_by": "timestamp",
"order_dir": "ASC",
"limit": 10,
"columns": ["timestamp", "event", "value", "user"],
"filters": [],
}
def test_database_types(tmp_path: Path) -> None:
csv_file = tmp_path / "events.csv"
csv_file.write_text(Path("scubaduck/sample.csv").read_text())
sqlite_file = tmp_path / "events.sqlite"
import sqlite3
conn = sqlite3.connect(sqlite_file)
conn.execute(
"CREATE TABLE events (timestamp TEXT, event TEXT, value INTEGER, user TE
XT)"
)
with open(csv_file) as f:
next(f)
for line in f:
ts, ev, val, user = line.strip().split(",")
conn.execute(
"INSERT INTO events VALUES (?, ?, ?, ?)", (ts, ev, int(val), use
r)
)
conn.commit()
conn.close() # pyright: ignore[reportUnknownMemberType, reportAttributeAcce
ssIssue]
duckdb_file = tmp_path / "events.duckdb"
con = duckdb.connect(duckdb_file)
con.execute(
f"CREATE TABLE events AS SELECT * FROM read_csv_auto('{csv_file.as_posix
()}')"
)
con.close() # pyright: ignore[reportUnknownMemberType, reportAttributeAcces
sIssue]
for db in (csv_file, sqlite_file, duckdb_file):
app = server.create_app(db)
client = app.test_client()
payload = _make_payload()
rv = client.post(
"/api/query", data=json.dumps(payload), content_type="application/js
on"
)
rows = rv.get_json()["rows"]
assert len(rows) == 3
def test_group_by_table() -> None:
app = server.app
client = app.test_client()
payload = {
"start": "2024-01-01 00:00:00",
"limit": 10,
"columns": ["value"],
"group_by": ["user"],
"aggregate": "Sum",
"show_hits": True,
}
rv = client.post(
"/api/query", data=json.dumps(payload), content_type="application/json"
)
rows = rv.get_json()["rows"]
assert rows[0][0] == "alice"
assert rows[0][1] == 2
assert rows[0][2] == 40
def test_relative_time_query(monkeypatch: pytest.MonkeyPatch) -> None:
app = server.app
client = app.test_client()
from datetime import datetime
fixed_now = datetime(2024, 1, 2, 4, 0, 0)
class FixedDateTime(datetime):
@classmethod
def now(cls, tz=None): # type: ignore[override]
return fixed_now if tz is None else fixed_now.astimezone(tz)
monkeypatch.setattr(server, "datetime", FixedDateTime)
payload = {
"start": "-1 hour",
"end": "now",
"order_by": "timestamp",
"limit": 100,
"columns": ["timestamp", "event", "value", "user"],
"filters": [],
}
rv = client.post(
"/api/query", data=json.dumps(payload), content_type="application/json"
)
data = rv.get_json()
assert rv.status_code == 200
assert len(data["rows"]) == 1
assert data["rows"][0][3] == "charlie"
def test_invalid_time_error() -> None:
app = server.app
client = app.test_client()
payload = {
"start": "nonsense",
"end": "now",
"order_by": "timestamp",
"limit": 10,
"columns": ["timestamp"],
"filters": [],
}
rv = client.post(
"/api/query", data=json.dumps(payload), content_type="application/json"
)
data = rv.get_json()
assert rv.status_code == 400
assert "error" in data
def test_query_error_returns_sql_and_traceback() -> None:
app = server.app
client = app.test_client()
payload = {
"start": "2024-01-01 00:00:00",
"end": "2024-01-03 00:00:00",
"columns": ["event"],
"group_by": ["user"],
"aggregate": "avg",
}
rv = client.post(
"/api/query", data=json.dumps(payload), content_type="application/json"
)
data = rv.get_json()
assert rv.status_code == 400
assert "error" in data
def test_table_unknown_column_error() -> None:
app = server.app
client = app.test_client()
payload = {
"start": "2024-01-01 00:00:00",
"end": "2024-01-03 00:00:00",
"graph_type": "table",
"order_by": "timestamp",
"limit": 100,
"columns": ["user", "Hits", "value"],
"group_by": ["user"],
"aggregate": "Count",
"show_hits": True,
}
rv = client.post(
"/api/query", data=json.dumps(payload), content_type="application/json"
)
data = rv.get_json()
assert rv.status_code == 400
assert "Unknown column" in data["error"]
def test_samples_view_rejects_group_by() -> None:
app = server.app
client = app.test_client()
payload = {
"graph_type": "samples",
"group_by": ["user"],
"columns": ["timestamp"],
}
rv = client.post(
"/api/query", data=json.dumps(payload), content_type="application/json"
)
data = rv.get_json()
assert rv.status_code == 400
assert "only valid" in data["error"]
I'll proceed with the file to make sure tests for parsing times are covered.
root@947ba2ae34e4:/workspace/scubaduck# sed -n '400,800p' tests/test_server.py
I'll mimic the UI flow: load page, switch to "Table" view, and run query.
I'll mimic user behavior: load page, set "table" view, run query with default aggregate.
I'll verify column selections on page load, ensuring non-string columns for table view.
I'll adjust the server to return the correct hit count and handle "Avg" aggregation correctly.
I'll create a test to check the average timestamp and ensure correct query results.
> from datetime import datetime
> import statistics
> rows = ['2024-01-01 00:00:00','2024-01-01 01:00:00','2024-01-02 00:00:00','202
4-01-02 03:00:00']
> secs=[datetime.strptime(x,'%Y-%m-%d %H:%M:%S').timestamp() for x in rows]
> print(sum(secs)/len(secs))
> from datetime import datetime, timezone
> avg= sum(secs)/len(secs)
> print(datetime.fromtimestamp(avg))
> EOF
1704114000.0
2024-01-01 13:00:00
I’ll create a test to check expected row values and a fix for query aggregation.
I can't check column types here, but Duckdb handles avg
for timestamp text types.
root@947ba2ae34e4:/workspace/scubaduck# python - <<'EOF'
> import duckdb
> con=duckdb.connect()
> con.execute("CREATE TABLE events AS SELECT * FROM read_csv_auto('scubaduck/sam
ple.csv')")
> print(con.execute('PRAGMA table_info(events)').fetchall())
> EOF
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'duckdb'
I realized I forgot to activate the virtual environment—time to run "source .venv/bin/activate".
root@947ba2ae34e4:/workspace/scubaduck# source .venv/bin/activate
(scubaduck) root@947ba2ae34e4:/workspace/scubaduck# python - <<'EOF'
> import duckdb
> con=duckdb.connect()
> con.execute("CREATE TABLE events AS SELECT * FROM read_csv_auto('scubaduck/sam
ple.csv')")
> print(con.execute('PRAGMA table_info(events)').fetchall())
> EOF
[(0, 'timestamp', 'TIMESTAMP', False, None, False), (1, 'event', 'VARCHAR', Fals
e, None, False), (2, 'value', 'BIGINT', False, None, False), (3, 'user', 'VARCHA
R', False, None, False)]
(scubaduck) root@947ba2ae34e4:/workspace/scubaduck#
I'll test running select avg(timestamp)
on the events table to see if it's allowed.
(scubaduck) root@947ba2ae34e4:/workspace/scubaduck# python - <<'EOF'
> import duckdb
> con=duckdb.connect()
> con.execute("CREATE TABLE events AS SELECT * FROM read_csv_auto('scubaduck/sam
ple.csv')")
> print(con.execute('select avg(timestamp) from events').fetchall())
> EOF
Traceback (most recent call last):
File "<stdin>", line 4, in <module>
duckdb.duckdb.BinderException: Binder Error: No function matches the given name
and argument types 'avg(TIMESTAMP)'. You might need to add explicit type casts.
Candidate functions:
avg(DECIMAL) -> DECIMAL
avg(SMALLINT) -> DOUBLE
avg(INTEGER) -> DOUBLE
avg(BIGINT) -> DOUBLE
avg(HUGEINT) -> DOUBLE
avg(DOUBLE) -> DOUBLE
LINE 1: select avg(timestamp) from events
^
(scubaduck) root@947ba2ae34e4:/workspace/scubaduck#
I'll try casting the timestamp to epoch using the epoch
function in Duckdb.
(scubaduck) root@947ba2ae34e4:/workspace/scubaduck# python - <<'EOF'
> import duckdb
> con=duckdb.connect()
> con.execute("CREATE TABLE events AS SELECT * FROM read_csv_auto('scubaduck/sam
ple.csv')")
> print(con.execute('select avg(UNIX_TIMESTAMP(timestamp)) from events').fetchal
l())
> EOF
Traceback (most recent call last):
File "<stdin>", line 4, in <module>
duckdb.duckdb.CatalogException: Catalog Error: Scalar Function with name unix_ti
mestamp does not exist!
Did you mean "to_timestamp"?
LINE 1: select avg(UNIX_TIMESTAMP(timestamp)) from events
^
(scubaduck) root@947ba2ae34e4:/workspace/scubaduck#
I'll look into how Duckdb uses the epoch
and epoch_ms
functions.
> import duckdb
> con=duckdb.connect()
> con.execute("SELECT epoch('2024-01-01 00:00:00'::timestamp)").fetchall()
> print(con.fetchall())
> EOF
[]
(scubaduck) root@947ba2ae34e4:/workspace/scubaduck#
I made a mistake—let's try printing the results instead.
(scubaduck) root@947ba2ae34e4:/workspace/scubaduck# python - <<'EOF'
> import duckdb
> con=duckdb.connect()
> rows = con.execute("SELECT epoch('2024-01-01 00:00:00'::TIMESTAMP)").fetchall(
)
> print(rows)
> EOF
[(1704067200.0,)]
(scubaduck) root@947ba2ae34e4:/workspace/scubaduck#
I'll compare the epoch time in seconds with epoch_ms
for accuracy.
(scubaduck) root@947ba2ae34e4:/workspace/scubaduck# python - <<'EOF'
> import duckdb
> con=duckdb.connect()
> rows = con.execute("SELECT epoch_ms('2024-01-01 00:00:00'::TIMESTAMP)").fetcha
ll()
> print(rows)
> EOF
[(1704067200000,)]
(scubaduck) root@947ba2ae34e4:/workspace/scubaduck#
I need to double-check how to convert an epoch back into a timestamp correctly.
(scubaduck) root@947ba2ae34e4:/workspace/scubaduck# python - <<'EOF'
> import duckdb, sys
> con=duckdb.connect()
> print(con.execute("SELECT to_timestamp(1704067200)").fetchall())
> print(con.execute("SELECT to_timestamp(1704067200000, 'ms')").fetchall())
> EOF
Traceback (most recent call last):
File "<stdin>", line 3, in <module>
duckdb.duckdb.InvalidInputException: Invalid Input Error: Required module 'pytz'
failed to import, due to the following Python exception:
ModuleNotFoundError: No module named 'pytz'
(scubaduck) root@947ba2ae34e4:/workspace/scubaduck#
Looks like to_timestamp needs 'pytz'. It’s not installed, so I’ll try using CAST
.
(scubaduck) root@947ba2ae34e4:/workspace/scubaduck# python - <<'EOF'
> import duckdb
> con=duckdb.connect()
> print(con.execute("SELECT CAST(1704067200000 AS TIMESTAMP)").fetchall())
> EOF
Traceback (most recent call last):
File "<stdin>", line 3, in <module>
duckdb.duckdb.ConversionException: Conversion Error: Unimplemented type for cast
(BIGINT -> TIMESTAMP)
LINE 1: SELECT CAST(1704067200000 AS TIMESTAMP)
^
(scubaduck) root@947ba2ae34e4:/workspace/scubaduck#
I'm looking into converting timestamps using epoch_ms()
and to_timestamp()
. There may be timezone issues since to_timestamp()
requires 'pytz', which might not be available. I'll check duckdb_functions()
for other options like EPOCH_MS
.
(scubaduck) root@947ba2ae34e4:/workspace/scubaduck# python - <<'EOF'
> import duckdb
> con=duckdb.connect()
> print(con.execute("SELECT epoch_ms('2024-01-01 00:00:00'::TIMESTAMP)").fetchal
l())
> print(con.execute("SELECT epoch_ms('2024-01-01 01:00:00'::TIMESTAMP)").fetchal
l())
> print(con.execute("SELECT epoch_ms('2024-01-02 00:00:00'::TIMESTAMP)").fetchal
l())
> print(con.execute("SELECT epoch_ms('2024-01-02 03:00:00'::TIMESTAMP)").fetchal
l())
> avg = con.execute("SELECT avg(epoch_ms(timestamp)) FROM read_csv_auto('scubadu
ck/sample.csv')").fetchone()[0]
> print('avgms', avg)
> print(con.execute("SELECT epoch_ms(to_timestamp(?,'ms'))", [avg]).fetchall())
> EOF
[(1704067200000,)]
[(1704070800000,)]
[(1704153600000,)]
[(1704164400000,)]
avgms 1704114000000.0
Traceback (most recent call last):
File "<stdin>", line 9, in <module>
duckdb.duckdb.BinderException: Binder Error: No function matches the given name
and argument types 'to_timestamp(DOUBLE, STRING_LITERAL)'. You might need to add
explicit type casts.
Candidate functions:
to_timestamp(DOUBLE) -> TIMESTAMP WITH TIME ZONE
LINE 1: SELECT epoch_ms(to_timestamp(?,'ms'))
^
(scubaduck) root@947ba2ae34e4:/workspace/scubaduck#
I’ll test converting milliseconds to seconds using to_timestamp
. I'll check epoch_ms
for bidirectional conversion.
(scubaduck) root@947ba2ae34e4:/workspace/scubaduck# python - <<'EOF'
> import duckdb
> con=duckdb.connect()
> print(con.execute("SELECT TIMESTAMP 'epoch' + INTERVAL '1 second' * 1704067200
").fetchall())
> print(con.execute("SELECT TIMESTAMP 'epoch' + INTERVAL '1 millisecond' * 17041
14000000").fetchall())
> EOF
[(datetime.datetime(2024, 1, 1, 0, 0),)]
Traceback (most recent call last):
File "<stdin>", line 4, in <module>
duckdb.duckdb.InvalidInputException: Invalid Input Error: Type INT64 with value
1704114000000 can't be cast because the value is out of range for the destinatio
n type INT32
(scubaduck) root@947ba2ae34e4:/workspace/scubaduck#
I need to use BIGINT for milliseconds to prevent overflow. Let's verify this approach.
> import duckdb
> con=duckdb.connect()
> print(con.execute("SELECT TIMESTAMP 'epoch' + 1704114000 * INTERVAL '1 second'
").fetchall())
> print(con.execute("SELECT TIMESTAMP 'epoch' + 1704114000000 * INTERVAL '1 mill
isecond'").fetchall())
> EOF
[(datetime.datetime(2024, 1, 1, 13, 0),)]
Traceback (most recent call last):
File "<stdin>", line 4, in <module>
duckdb.duckdb.InvalidInputException: Invalid Input Error: Type INT64 with value
1704114000000 can't be cast because the value is out of range for the destinatio
n type INT32
(scubaduck) root@947ba2ae34e4:/workspace/scubaduck#
The integer 1704114000000 exceeds the int32 limit, so I'll cast it to BIGINT or DECIMAL.
(scubaduck) root@947ba2ae34e4:/workspace/scubaduck# python - <<'EOF'
> import duckdb
> con=duckdb.connect()
> print(con.execute("SELECT TIMESTAMP 'epoch' + CAST(1704114000000 AS BIGINT) *
INTERVAL '1 millisecond'").fetchall())
> EOF
Traceback (most recent call last):
File "<stdin>", line 3, in <module>
duckdb.duckdb.InvalidInputException: Invalid Input Error: Type INT64 with value
1704114000000 can't be cast because the value is out of range for the destinatio
n type INT32
(scubaduck) root@947ba2ae34e4:/workspace/scubaduck#
Maybe using "1704114000000" as a string and casting it to BIGINT will solve this.
(scubaduck) root@947ba2ae34e4:/workspace/scubaduck# python - <<'EOF'
> import duckdb
> con=duckdb.connect()
> print(con.execute("SELECT TIMESTAMP 'epoch' + CAST('1704114000000' AS BIGINT)
* INTERVAL '1 millisecond'").fetchall())
> EOF
Traceback (most recent call last):
File "<stdin>", line 3, in <module>
duckdb.duckdb.InvalidInputException: Invalid Input Error: Type INT64 with value
1704114000000 can't be cast because the value is out of range for the destinatio
n type INT32
(scubaduck) root@947ba2ae34e4:/workspace/scubaduck#
Looks like a 32-bit issue—13-digit numbers may be misinterpreted as 32-bit integers.
(scubaduck) root@947ba2ae34e4:/workspace/scubaduck# python - <<'EOF'
> import duckdb
> con=duckdb.connect()
> print(con.execute("SELECT 1704114000000::BIGINT").fetchall())
> print(con.execute("SELECT 1704114000000::HUGEINT").fetchall())
> EOF
[(1704114000000,)]
[(1704114000000,)]
(scubaduck) root@947ba2ae34e4:/workspace/scubaduck#
I'll work on computing the timestamp from 1704114000000::BIGINT.
(scubaduck) root@947ba2ae34e4:/workspace/scubaduck# python - <<'EOF'
> import duckdb
> con=duckdb.connect()
> print(con.execute("SELECT TIMESTAMP 'epoch' + 1704114000 * INTERVAL '1 second'
").fetchall())
> print(con.execute("SELECT TIMESTAMP 'epoch' + 1704114000000::BIGINT * INTERVAL
'1 millisecond'").fetchall())
> EOF
[(datetime.datetime(2024, 1, 1, 13, 0),)]
Traceback (most recent call last):
File "<stdin>", line 4, in <module>
duckdb.duckdb.InvalidInputException: Invalid Input Error: Type INT64 with value
1704114000000 can't be cast because the value is out of range for the destinatio
n type INT32
(scubaduck) root@947ba2ae34e4:/workspace/scubaduck#
The INTERVAL type might be causing issues, so I'll try adjusting the multiplier with timestamps.
> import duckdb
> con=duckdb.connect()
> print(con.execute("SELECT TIMESTAMP 'epoch' + (1704114000000::BIGINT / 1000) *
INTERVAL '1 second'").fetchall())
> EOF
Traceback (most recent call last):
File "<stdin>", line 3, in <module>
duckdb.duckdb.BinderException: Binder Error: No function matches the given name
and argument types '*(DOUBLE, INTERVAL)'. You might need to add explicit type ca
sts.
Candidate functions:
*(TINYINT, TINYINT) -> TINYINT
*(SMALLINT, SMALLINT) -> SMALLINT
*(INTEGER, INTEGER) -> INTEGER
*(BIGINT, BIGINT) -> BIGINT
*(HUGEINT, HUGEINT) -> HUGEINT
*(FLOAT, FLOAT) -> FLOAT
*(DOUBLE, DOUBLE) -> DOUBLE
*(DECIMAL, DECIMAL) -> DECIMAL
*(UTINYINT, UTINYINT) -> UTINYINT
*(USMALLINT, USMALLINT) -> USMALLINT
*(UINTEGER, UINTEGER) -> UINTEGER
*(UBIGINT, UBIGINT) -> UBIGINT
*(UHUGEINT, UHUGEINT) -> UHUGEINT
*(INTERVAL, BIGINT) -> INTERVAL
*(BIGINT, INTERVAL) -> INTERVAL
LINE 1: SELECT TIMESTAMP 'epoch' + (1704114000000::BIGINT / 1000) * INTERVAL '1
second'
^
(scubaduck) root@947ba2ae34e4:/workspace/scubaduck#
I'll see if there's a built-in function to convert epoch seconds to timestamp.
(scubaduck) root@947ba2ae34e4:/workspace/scubaduck# python - <<'EOF'
> import duckdb
> con=duckdb.connect()
> print(con.execute("select name from duckdb_functions() where name ilike '%epoc
h%'").fetchall())
> EOF
Traceback (most recent call last):
File "<stdin>", line 3, in <module>
duckdb.duckdb.BinderException: Binder Error: Referenced column "name" not found
in FROM clause!
Candidate bindings: "parameters", "parameter_types", "examples", "comment", "int
ernal"
LINE 1: select name from duckdb_functions() where name ilike '%epoch%'
^
(scubaduck) root@947ba2ae34e4:/workspace/scubaduck#
I'll run duckdb_functions()
to check whether the function is accessible.
> import duckdb
> con=duckdb.connect()
> con.execute("PRAGMA functions");
> rows = con.fetchall()
> print(rows[:10])
> EOF
[('!__postfix', 'SCALAR', ['INTEGER'], None, 'HUGEINT', False), ('!~~', 'SCALAR'
, ['VARCHAR', 'VARCHAR'], None, 'BOOLEAN', False), ('!~~*', 'SCALAR', ['VARCHAR'
, 'VARCHAR'], None, 'BOOLEAN', False), ('%', 'SCALAR', ['UHUGEINT', 'UHUGEINT'],
None, 'UHUGEINT', False), ('%', 'SCALAR', ['TINYINT', 'TINYINT'], None, 'TINYIN
T', False), ('%', 'SCALAR', ['SMALLINT', 'SMALLINT'], None, 'SMALLINT', False),
('%', 'SCALAR', ['INTEGER', 'INTEGER'], None, 'INTEGER', False), ('%', 'SCALAR',
['BIGINT', 'BIGINT'], None, 'BIGINT', False), ('%', 'SCALAR', ['HUGEINT', 'HUGE
INT'], None, 'HUGEINT', False), ('%', 'SCALAR', ['FLOAT', 'FLOAT'], None, 'FLOAT
', False)]
(scubaduck) root@947ba2ae34e4:/workspace/scubaduck#
I can't access docs, so I'll implement the timestamp conversion directly in SQL using epoch.
(scubaduck) root@947ba2ae34e4:/workspace/scubaduck# python - <<'EOF'
> import duckdb
> con=duckdb.connect()
> res = con.execute("SELECT TIMESTAMP '1970-01-01 00:00:00' + 1704114000 * INTER
VAL '1 second'").fetchall()
> print(res)
> EOF
[(datetime.datetime(2024, 1, 1, 13, 0),)]
(scubaduck) root@947ba2ae34e4:/workspace/scubaduck#
I think I can modify build_query
to accept column_types
to solve the timestamp issue.
(scubaduck) root@947ba2ae34e4:/workspace/scubaduck# grep -R "build_query" -n
scubaduck/server.py:101:def build_query(params: QueryParams) -> str:
scubaduck/server.py:323: sql = build_query(params)
I'm changing build_query to accept column_types
, making the necessary adjustments in query()
.
I'm modifying agg_expr
for correct handling of time columns and aggregation when no group-by.
I'm updating create_app
to pass column_types
to build_query
and handling timestamps.
(scubaduck) root@947ba2ae34e4:/workspace/scubaduck# python - <<'EOF'
> import duckdb
> con=duckdb.connect()
> con.execute("CREATE TABLE events AS SELECT * FROM read_csv_auto('scubaduck/sam
ple.csv')")
> print(con.execute("SELECT TIMESTAMP 'epoch' + avg(epoch(timestamp)) * INTERVAL
'1 second' FROM events").fetchall())
> EOF
Traceback (most recent call last):
File "<stdin>", line 4, in <module>
duckdb.duckdb.BinderException: Binder Error: No function matches the given name
and argument types '*(DOUBLE, INTERVAL)'. You might need to add explicit type ca
sts.
Candidate functions:
*(TINYINT, TINYINT) -> TINYINT
*(SMALLINT, SMALLINT) -> SMALLINT
*(INTEGER, INTEGER) -> INTEGER
*(BIGINT, BIGINT) -> BIGINT
*(HUGEINT, HUGEINT) -> HUGEINT
*(FLOAT, FLOAT) -> FLOAT
*(DOUBLE, DOUBLE) -> DOUBLE
*(DECIMAL, DECIMAL) -> DECIMAL
*(UTINYINT, UTINYINT) -> UTINYINT
*(USMALLINT, USMALLINT) -> USMALLINT
*(UINTEGER, UINTEGER) -> UINTEGER
*(UBIGINT, UBIGINT) -> UBIGINT
*(UHUGEINT, UHUGEINT) -> UHUGEINT
*(INTERVAL, BIGINT) -> INTERVAL
*(BIGINT, INTERVAL) -> INTERVAL
LINE 1: SELECT TIMESTAMP 'epoch' + avg(epoch(timestamp)) * INTERVAL '1 second' F
ROM events
^
(scubaduck) root@947ba2ae34e4:/workspace/scubaduck#
I need to cast the double to BIGINT or DECIMAL before multiplying. Testing now.
> import duckdb
> con=duckdb.connect()
> con.execute("CREATE TABLE events AS SELECT * FROM read_csv_auto('scubaduck/sam
ple.csv')")
> print(con.execute("SELECT TIMESTAMP 'epoch' + INTERVAL '1 second' * avg(epoch(
timestamp)) FROM events").fetchall())
> EOF
Traceback (most recent call last):
File "<stdin>", line 4, in <module>
duckdb.duckdb.BinderException: Binder Error: No function matches the given name
and argument types '*(INTERVAL, DOUBLE)'. You might need to add explicit type ca
sts.
Candidate functions:
*(TINYINT, TINYINT) -> TINYINT
*(SMALLINT, SMALLINT) -> SMALLINT
*(INTEGER, INTEGER) -> INTEGER
*(BIGINT, BIGINT) -> BIGINT
*(HUGEINT, HUGEINT) -> HUGEINT
*(FLOAT, FLOAT) -> FLOAT
*(DOUBLE, DOUBLE) -> DOUBLE
*(DECIMAL, DECIMAL) -> DECIMAL
*(UTINYINT, UTINYINT) -> UTINYINT
*(USMALLINT, USMALLINT) -> USMALLINT
*(UINTEGER, UINTEGER) -> UINTEGER
*(UBIGINT, UBIGINT) -> UBIGINT
*(UHUGEINT, UHUGEINT) -> UHUGEINT
*(INTERVAL, BIGINT) -> INTERVAL
*(BIGINT, INTERVAL) -> INTERVAL
LINE 1: SELECT TIMESTAMP 'epoch' + INTERVAL '1 second' * avg(epoch(timestamp)) F
ROM events
^
(scubaduck) root@947ba2ae34e4:/workspace/scubaduck#
I’ll cast to BIGINT to get the timestamp in seconds, then multiply by an interval.
(scubaduck) root@947ba2ae34e4:/workspace/scubaduck# python - <<'EOF'
> import duckdb
> con=duckdb.connect()
> con.execute("CREATE TABLE events AS SELECT * FROM read_csv_auto('scubaduck/sam
ple.csv')")
> print(con.execute("SELECT TIMESTAMP 'epoch' + INTERVAL '1 second' * CAST(avg(e
poch(timestamp)) AS BIGINT) FROM events").fetchall())
> EOF
[(datetime.datetime(2024, 1, 1, 13, 0),)]
(scubaduck) root@947ba2ae34e4:/workspace/scubaduck#
I’ll try using avg(epoch_ms(column))
and multiplying by milliseconds, casting to BIGINT.
> import duckdb
> con=duckdb.connect()
> con.execute("CREATE TABLE events AS SELECT * FROM read_csv_auto('scubaduck/sam
ple.csv')")
> print(con.execute("SELECT TIMESTAMP 'epoch' + INTERVAL '1 millisecond' * CAST(
avg(epoch_ms(timestamp)) AS BIGINT) FROM events").fetchall())
> EOF
Traceback (most recent call last):
File "<stdin>", line 4, in <module>
duckdb.duckdb.InvalidInputException: Invalid Input Error: Type INT64 with value
1704114000000 can't be cast because the value is out of range for the destinatio
n type INT32
(scubaduck) root@947ba2ae34e4:/workspace/scubaduck#
It seems unnecessary to cast constants to BIGINT since epoch_ms already returns BIGINT.
(scubaduck) root@947ba2ae34e4:/workspace/scubaduck# python - <<'EOF'
> import duckdb
> con=duckdb.connect()
> print(con.execute("SELECT INTERVAL '1 millisecond' * 1700::BIGINT").fetchall()
)
> print(con.execute("SELECT 1700::BIGINT * INTERVAL '1 millisecond'").fetchall()
)
> EOF
[(datetime.timedelta(seconds=1, microseconds=700000),)]
[(datetime.timedelta(seconds=1, microseconds=700000),)]
(scubaduck) root@947ba2ae34e4:/workspace/scubaduck#
The error occurred due to mismatched data types, but casting should fix it. Let's test.
(scubaduck) root@947ba2ae34e4:/workspace/scubaduck# python - <<'EOF'
> import duckdb
> con=duckdb.connect()
> con.execute("CREATE TABLE events AS SELECT * FROM read_csv_auto('scubaduck/sam
ple.csv')")
> print(con.execute("SELECT TIMESTAMP 'epoch' + INTERVAL '1 second' * CAST(avg(e
poch(timestamp)) AS BIGINT) FROM events").fetchall())
> EOF
[(datetime.datetime(2024, 1, 1, 13, 0),)]
(scubaduck) root@947ba2ae34e4:/workspace/scubaduck#
I'm adjusting the query building for aggregation and handling edge cases for group_by and show_hits.
I'll create a test for the case with no group_by but aggregate is applied.
(scubaduck) root@947ba2ae34e4:/workspace/scubaduck# git status --short
(scubaduck) root@947ba2ae34e4:/workspace/scubaduck#
The repo is clean, so I'm ready to start implementing the patch now.
dt = dtparser.parse(s)
return dt.replace(microsecond=0, tzinfo=None).strftime("%Y-%m-%d %H:%M:%S")
def build_query(params: QueryParams) -> str:
select_parts: list[str] = []
if params.group_by:
select_parts.extend(params.group_by)
agg = (params.aggregate or "avg").lower()
def agg_expr(col: str) -> str:
if agg.startswith("p"):
quant = float(agg[1:]) / 100
return f"quantile({col}, {quant})"
if agg == "count distinct":
return f"count(DISTINCT {col})"
return f"{agg}({col})"
for col in params.columns:
if col in params.group_by:
continue
select_parts.append(f"{agg_expr(col)} AS {col}")
if params.show_hits:
select_parts.insert(len(params.group_by), "count(*) AS Hits")
else:
select_parts.extend(params.columns)
for name, expr in params.derived_columns.items():
select_parts.append(f"{expr} AS {name}")
select_clause = ", ".join(select_parts) if select_parts else "*"
query = f"SELECT {select_clause} FROM events"
where_parts: list[str] = []
if params.start:
where_parts.append(f"timestamp >= '{params.start}'")
if params.end:
where_parts.append(f"timestamp <= '{params.end}'")
for f in params.filters:
op = f.op
if op in {"empty", "!empty"}:
val = "''"
else:
if f.value is None:
continue
if isinstance(f.value, list):
if not f.value:
continue
if op == "=":
vals = " OR ".join(f"{f.column} = '{v}'" for v in f.value)
where_parts.append(f"({vals})")
continue
val = f"'{f.value}'" if isinstance(f.value, str) else str(f.value)
if op == "contains":
where_parts.append(f"{f.column} ILIKE '%' || {val} || '%'")
elif op == "!contains":
where_parts.append(f"{f.column} NOT ILIKE '%' || {val} || '%'")
elif op == "empty":
where_parts.append(f"{f.column} = {val}")
elif op == "!empty":
where_parts.append(f"{f.column} != {val}")
else:
where_parts.append(f"{f.column} {op} {val}")
if where_parts:
query += " WHERE " + " AND ".join(where_parts)
if params.group_by:
query += " GROUP BY " + ", ".join(params.group_by)
if params.order_by:
query += f" ORDER BY {params.order_by} {params.order_dir}"
if params.limit is not None:
query += f" LIMIT {params.limit}"
return query
def create_app(db_file: str | Path | None = None) -> Flask:
app = Flask(__name__, static_folder="static")
db_path = Path(db_file or Path(__file__).with_name("sample.csv")).resolve()
con = _load_database(db_path)
column_types: Dict[str, str] = {
r[1]: r[2] for r in con.execute("PRAGMA table_info(events)").fetchall()
}
sample_cache: Dict[Tuple[str, str], Tuple[List[str], float]] = {}
CACHE_TTL = 60.0
CACHE_LIMIT = 200
(scubaduck) root@947ba2ae34e4:/workspace/scubaduck#
I'll go ahead and apply the changes to the functions now.
> *** Begin Patch
> *** Update File: scubaduck/server.py
> @@
> -def build_query(params: QueryParams) -> str:
> - select_parts: list[str] = []
> - if params.group_by:
> - select_parts.extend(params.group_by)
> - agg = (params.aggregate or "avg").lower()
> -
> - def agg_expr(col: str) -> str:
> - if agg.startswith("p"):
> - quant = float(agg[1:]) / 100
> - return f"quantile({col}, {quant})"
> - if agg == "count distinct":
> - return f"count(DISTINCT {col})"
> - return f"{agg}({col})"
> -
> - for col in params.columns:
> - if col in params.group_by:
> - continue
> - select_parts.append(f"{agg_expr(col)} AS {col}")
> - if params.show_hits:
> - select_parts.insert(len(params.group_by), "count(*) AS Hits")
> - else:
> - select_parts.extend(params.columns)
> +def build_query(params: QueryParams, column_types: Dict[str, str] | None = No
ne) -> str:
> + select_parts: list[str] = []
> + has_agg = bool(params.group_by) or params.aggregate is not None
> + if has_agg:
> + select_parts.extend(params.group_by)
> + agg = (params.aggregate or "avg").lower()
> +
> + def agg_expr(col: str) -> str:
> + if agg.startswith("p"):
> + quant = float(agg[1:]) / 100
> + return f"quantile({col}, {quant})"
> + if agg == "count distinct":
> + return f"count(DISTINCT {col})"
> + if agg == "avg" and column_types is not None:
> + ctype = column_types.get(col, "").upper()
> + if "TIMESTAMP" in ctype or "DATE" in ctype or "TIME" in ctype
:
> + return (
> + "TIMESTAMP 'epoch' + INTERVAL '1 second' * "
> + f"CAST(avg(epoch({col})) AS BIGINT)"
> + )
> + return f"{agg}({col})"
> +
> + for col in params.columns:
> + if col in params.group_by:
> + continue
> + select_parts.append(f"{agg_expr(col)} AS {col}")
> + if params.show_hits:
> + select_parts.insert(len(params.group_by), "count(*) AS Hits")
> + else:
> + select_parts.extend(params.columns)
> *** End Patch
> PATCH
Success. Updated the following files:
M scubaduck/server.py
(scubaduck) root@947ba2ae34e4:/workspace/scubaduck#
I need to update the call to build_query within the query function.
(scubaduck) root@947ba2ae34e4:/workspace/scubaduck# grep -n "build_query" -n scu
baduck/server.py
101:def build_query(params: QueryParams, column_types: Dict[str, str] | None = N
one) -> str:
331: sql = build_query(params)
(scubaduck) root@947ba2ae34e4:/workspace/scubaduck#
I'll adjust the function call on line 331.
(scubaduck) root@947ba2ae34e4:/workspace/scubaduck# sed -n '320,360p' scubaduck/
server.py
400,
)
if allow_time and not (is_numeric or is_time):
return (
jsonify(
{
"error": f"Aggregate {agg} cannot be applied
to column {c}",
}
),
400,
)
sql = build_query(params)
try:
rows = con.execute(sql).fetchall()
except Exception as exc:
tb = traceback.format_exc()
print(f"Query failed:\n{sql}\n{tb}")
return (
jsonify({"sql": sql, "error": str(exc), "traceback": tb}),
400,
)
return jsonify({"sql": sql, "rows": rows})
return app
app = create_app()
if __name__ == "__main__":
app.run(debug=True)
(scubaduck) root@947ba2ae34e4:/workspace/scubaduck#
I'll modify the function call to pass the column_types parameter.
(scubaduck) root@947ba2ae34e4:/workspace/scubaduck# apply_patch<<'PATCH'
> *** Begin Patch
> *** Update File: scubaduck/server.py
> @@
> - sql = build_query(params)
> + sql = build_query(params, column_types)
> *** End Patch
> PATCH
Success. Updated the following files:
M scubaduck/server.py
(scubaduck) root@947ba2ae34e4:/workspace/scubaduck#
Time to add the tests in tests/test_web.py
and apply the patch.
(scubaduck) root@947ba2ae34e4:/workspace/scubaduck# grep -n "test_table_group_by
_query" -n tests/test_web.py
608:def test_table_group_by_query(page: Any, server_url: str) -> None:
(scubaduck) root@947ba2ae34e4:/workspace/scubaduck#
I'll try adding a new test after the test_table_group_by_query
section.
page.goto(f"{server_url}?graph_type=table")
page.wait_for_selector("#group_by_field", state="visible")
border = page.evaluate(
"getComputedStyle(document.querySelector('#group_by_field .f-val')).bord
erStyle"
)
assert border == "none"
def test_table_group_by_query(page: Any, server_url: str) -> None:
data = run_query(
page,
server_url,
start="2024-01-01 00:00:00",
end="2024-01-03 00:00:00",
order_by="timestamp",
limit=100,
group_by=["user"],
aggregate="Count",
)
assert "error" not in data
assert len(data["rows"]) == 3
(scubaduck) root@947ba2ae34e4:/workspace/scubaduck#
I'll add a new test following this change.
server_url,
start="2024-01-01 00:00:00",
end="2024-01-03 00:00:00",
order_by="timestamp",
limit=100,
group_by=["user"],
aggregate="Count",
)
assert "error" not in data
assert len(data["rows"]) == 3
(scubaduck) root@947ba2ae34e4:/workspace/scubaduck#
I’ll add a new test right after the file ends and implement it.
(scubaduck) root@947ba2ae34e4:/workspace/scubaduck# apply_patch<<'PATCH'
> *** Begin Patch
> *** Update File: tests/test_web.py
> @@
> def test_table_group_by_query(page: Any, server_url: str) -> None:
> @@
> assert len(data["rows"]) == 3
> +
> +
> +def test_table_avg_no_group_by(page: Any, server_url: str) -> None:
> + data = run_query(
> + page,
> + server_url,
> + aggregate="Avg",
> + )
> + assert len(data["rows"]) == 1
> + row = data["rows"][0]
> + assert row[0] == 4
> + from dateutil import parser
> +
> + ts = parser.parse(row[1]).replace(tzinfo=None)
> + assert ts == parser.parse("2024-01-01 13:00:00")
> + assert row[2] == 25
> *** End Patch
> PATCH
Success. Updated the following files:
M tests/test_web.py
(scubaduck) root@947ba2ae34e4:/workspace/scubaduck#
I'll run formatting, linting, and type checks after the test insert.
(scubaduck) root@947ba2ae34e4:/workspace/scubaduck# ruff format scubaduck/server
.py tests/test_web.py
2 files left unchanged
(scubaduck) root@947ba2ae34e4:/workspace/scubaduck#
I'll go ahead and run the ruff linter to check for issues.
py tests/test_web.py
All checks passed!
(scubaduck) root@947ba2ae34e4:/workspace/scubaduck#
It seems like ruff check passed. Now, I'll move on to running pyright.
(scubaduck) root@947ba2ae34e4:/workspace/scubaduck# pyright scubaduck/server.py
tests/test_web.py > /tmp/pyright.log && tail -n 20 /tmp/pyright.log
0 errors, 0 warnings, 0 informations
(scubaduck) root@947ba2ae34e4:/workspace/scubaduck#
I'll run all tests per the instructions, even though I can't show the failing ones yet.
(scubaduck) root@947ba2ae34e4:/workspace/scubaduck# pytest -q > /tmp/pytest.log
&& tail -n 20 /tmp/pytest.log
bringing up nodes...
bringing up nodes...
............................................ [100%]
44 passed in 8.61s
(scubaduck) root@947ba2ae34e4:/workspace/scubaduck#
Tests passed, now I’m taking a look at the logs for more details.
(scubaduck) root@947ba2ae34e4:/workspace/scubaduck# tail -n 20 /tmp/pytest.log
bringing up nodes...
bringing up nodes...
............................................ [100%]
44 passed in 8.61s
(scubaduck) root@947ba2ae34e4:/workspace/scubaduck#
Time to commit the changes I've made now!
(scubaduck) root@947ba2ae34e4:/workspace/scubaduck# git status --short
M scubaduck/server.py
M tests/test_web.py
(scubaduck) root@947ba2ae34e4:/workspace/scubaduck# git add scubaduck/server.py
tests/test_web.py
(scubaduck) root@947ba2ae34e4:/workspace/scubaduck# git commit -m "test: verify
table avg without group" && git status --short
[work db62067] test: verify table avg without group
2 files changed, 27 insertions(+), 3 deletions(-)
(scubaduck) root@947ba2ae34e4:/workspace/scubaduck#
I see the commit message should reflect the server fix, not just the test.
commit db620676d4bc38f3d7ee1d48e8ea96d41d0e1829 (HEAD -> work)
Author: Codex <codex@openai.com>
Date: Wed May 21 02:35:14 2025 +0000
test: verify table avg without group
scubaduck/server.py | 14 +++++++++++---
tests/test_web.py | 16 ++++++++++++++++
2 files changed, 27 insertions(+), 3 deletions(-)
(scubaduck) root@947ba2ae34e4:/workspace/scubaduck#
The commit message shouldn't be modified, so I'll leave it as is for now. I'll check for uncommitted changes.
(scubaduck) root@947ba2ae34e4:/workspace/scubaduck#
I'll grab the lines from server.py that correspond to the changes I made.
(scubaduck) root@947ba2ae34e4:/workspace/scubaduck# nl -ba scubaduck/server.py |
sed -n '98,148p'
98 return dt.replace(microsecond=0, tzinfo=None).strftime("%Y-%m-%d %H:
%M:%S")
99
100
101 def build_query(params: QueryParams, column_types: Dict[str, str] | None
= None) -> str:
102 select_parts: list[str] = []
103 has_agg = bool(params.group_by) or params.aggregate is not None
104 if has_agg:
105 select_parts.extend(params.group_by)
106 agg = (params.aggregate or "avg").lower()
107
108 def agg_expr(col: str) -> str:
109 if agg.startswith("p"):
110 quant = float(agg[1:]) / 100
111 return f"quantile({col}, {quant})"
112 if agg == "count distinct":
113 return f"count(DISTINCT {col})"
114 if agg == "avg" and column_types is not None:
115 ctype = column_types.get(col, "").upper()
116 if "TIMESTAMP" in ctype or "DATE" in ctype or "TIME" in
ctype:
117 return (
118 "TIMESTAMP 'epoch' + INTERVAL '1 second' * "
119 f"CAST(avg(epoch({col})) AS BIGINT)"
120 )
121 return f"{agg}({col})"
122
123 for col in params.columns:
124 if col in params.group_by:
125 continue
126 select_parts.append(f"{agg_expr(col)} AS {col}")
127 if params.show_hits:
128 select_parts.insert(len(params.group_by), "count(*) AS Hits"
)
129 else:
130 select_parts.extend(params.columns)
131 for name, expr in params.derived_columns.items():
132 select_parts.append(f"{expr} AS {name}")
133 select_clause = ", ".join(select_parts) if select_parts else "*"
134 query = f"SELECT {select_clause} FROM events"
135 where_parts: list[str] = []
136 if params.start:
137 where_parts.append(f"timestamp >= '{params.start}'")
138 if params.end:
139 where_parts.append(f"timestamp <= '{params.end}'")
140 for f in params.filters:
141 op = f.op
142 if op in {"empty", "!empty"}:
143 val = "''"
144 else:
145 if f.value is None:
146 continue
147 if isinstance(f.value, list):
148 if not f.value:
(scubaduck) root@947ba2ae34e4:/workspace/scubaduck#
I need to identify the line ranges near the call modification.
(scubaduck) root@947ba2ae34e4:/workspace/scubaduck# nl -ba scubaduck/server.py |
sed -n '328,336p'
328 ),
329 400,
330 )
331 sql = build_query(params, column_types)
332 try:
333 rows = con.execute(sql).fetchall()
334 except Exception as exc:
335 tb = traceback.format_exc()
336 print(f"Query failed:\n{sql}\n{tb}")
(scubaduck) root@947ba2ae34e4:/workspace/scubaduck#
I'm grabbing the lines from tests/test_web.py to add a new test.
(scubaduck) root@947ba2ae34e4:/workspace/scubaduck# nl -ba tests/test_web.py | s
ed -n '608,630p'
608 def test_table_group_by_query(page: Any, server_url: str) -> None:
609 data = run_query(
610 page,
611 server_url,
612 start="2024-01-01 00:00:00",
613 end="2024-01-03 00:00:00",
614 order_by="timestamp",
615 limit=100,
616 group_by=["user"],
617 aggregate="Count",
618 )
619 assert "error" not in data
620 assert len(data["rows"]) == 3
621
622
623 def test_table_avg_no_group_by(page: Any, server_url: str) -> None:
624 data = run_query(
625 page,
626 server_url,
627 aggregate="Avg",
628 )
629 assert len(data["rows"]) == 1
630 row = data["rows"][0]
(scubaduck) root@947ba2ae34e4:/workspace/scubaduck# nl -ba tests/test_web.py | s
ed -n '630,650p'
630 row = data["rows"][0]
631 assert row[0] == 4
632 from dateutil import parser
633
634 ts = parser.parse(row[1]).replace(tzinfo=None)
635 assert ts == parser.parse("2024-01-01 13:00:00")
636 assert row[2] == 25
(scubaduck) root@947ba2ae34e4:/workspace/scubaduck#
I'll gather line ranges first, then craft the PR message with test references.