Task ID: task_e_682ea221f9d48323a8dd5caeef57ba89
Building scubaduck @ file:///workspace/scubaduck
⠙ Preparing packages... (0/33)
pytest-base-url ------------------------------ 5.18 KiB/5.18 KiB
blinker ------------------------------ 8.00 KiB/8.26 KiB
pyee ------------------------------ 15.36 KiB/15.36 KiB
pluggy ------------------------------ 20.06 KiB/20.06 KiB
execnet ------------------------------ 30.88 KiB/39.66 KiB
typing-extensions ------------------------------ 44.73 KiB/44.73 KiB
pytest-xdist ------------------------------ 30.90 KiB/45.03 KiB
requests ------------------------------ 46.88 KiB/63.41 KiB
packaging ------------------------------ 64.91 KiB/64.91 KiB
text-unidecode ------------------------------ 76.32 KiB/76.32 KiB
click ------------------------------ 99.76 KiB/99.76 KiB
flask ------------------------------ 78.88 KiB/100.88 KiB
urllib3 ------------------------------ 78.64 KiB/125.66 KiB
jinja2 ------------------------------ 46.88 KiB/131.74 KiB
charset-normalizer ------------------------------ 128.00 KiB/145.08 KiB
certifi ------------------------------ 155.88 KiB/155.88 KiB
werkzeug ------------------------------ 93.06 KiB/219.24 KiB
python-dateutil ------------------------------ 48.00 KiB/224.50 KiB
pytest ------------------------------ 77.57 KiB/335.58 KiB
greenlet ------------------------------ 48.00 KiB/589.71 KiB
pyright ------------------------------ 16.00 KiB/5.31 MiB
ruff ------------------------------ 142.91 KiB/11.02 MiB
Building scubaduck @ file:///workspace/scubaduck
⠙ Preparing packages... (0/33)
pytest-base-url ------------------------------ 5.18 KiB/5.18 KiB
pyee ------------------------------ 15.36 KiB/15.36 KiB
pluggy ------------------------------ 20.06 KiB/20.06 KiB
execnet ------------------------------ 30.88 KiB/39.66 KiB
typing-extensions ------------------------------ 44.73 KiB/44.73 KiB
pytest-xdist ------------------------------ 45.03 KiB/45.03 KiB
requests ------------------------------ 46.88 KiB/63.41 KiB
packaging ------------------------------ 64.91 KiB/64.91 KiB
text-unidecode ------------------------------ 76.32 KiB/76.32 KiB
click ------------------------------ 99.76 KiB/99.76 KiB
flask ------------------------------ 78.88 KiB/100.88 KiB
urllib3 ------------------------------ 78.64 KiB/125.66 KiB
jinja2 ------------------------------ 46.88 KiB/131.74 KiB
charset-normalizer ------------------------------ 128.00 KiB/145.08 KiB
certifi ------------------------------ 155.88 KiB/155.88 KiB
werkzeug ------------------------------ 93.06 KiB/219.24 KiB
python-dateutil ------------------------------ 48.00 KiB/224.50 KiB
pytest ------------------------------ 77.57 KiB/335.58 KiB
greenlet ------------------------------ 48.00 KiB/589.71 KiB
pyright ------------------------------ 16.00 KiB/5.31 MiB
ruff ------------------------------ 158.91 KiB/11.02 MiB
duckdb ------------------------------ 64.00 KiB/19.27 MiB
Building scubaduck @ file:///workspace/scubaduck
⠙ Preparing packages... (0/33)
pytest-base-url ------------------------------ 5.18 KiB/5.18 KiB
pyee ------------------------------ 15.36 KiB/15.36 KiB
execnet ------------------------------ 30.88 KiB/39.66 KiB
typing-extensions ------------------------------ 44.73 KiB/44.73 KiB
pytest-xdist ------------------------------ 45.03 KiB/45.03 KiB
requests ------------------------------ 46.88 KiB/63.41 KiB
packaging ------------------------------ 64.91 KiB/64.91 KiB
text-unidecode ------------------------------ 76.32 KiB/76.32 KiB
click ------------------------------ 99.76 KiB/99.76 KiB
flask ------------------------------ 78.88 KiB/100.88 KiB
urllib3 ------------------------------ 78.64 KiB/125.66 KiB
jinja2 ------------------------------ 46.88 KiB/131.74 KiB
charset-normalizer ------------------------------ 128.00 KiB/145.08 KiB
certifi ------------------------------ 155.88 KiB/155.88 KiB
werkzeug ------------------------------ 93.06 KiB/219.24 KiB
python-dateutil ------------------------------ 48.00 KiB/224.50 KiB
pytest ------------------------------ 77.57 KiB/335.58 KiB
greenlet ------------------------------ 48.00 KiB/589.71 KiB
pyright ------------------------------ 16.00 KiB/5.31 MiB
ruff ------------------------------ 174.91 KiB/11.02 MiB
duckdb ------------------------------ 80.00 KiB/19.27 MiB
playwright ------------------------------ 32.00 KiB/43.05 MiB
Building scubaduck @ file:///workspace/scubaduck
⠙ Preparing packages... (0/33)
pyee ------------------------------ 15.36 KiB/15.36 KiB
execnet ------------------------------ 30.88 KiB/39.66 KiB
typing-extensions ------------------------------ 44.73 KiB/44.73 KiB
pytest-xdist ------------------------------ 45.03 KiB/45.03 KiB
requests ------------------------------ 46.88 KiB/63.41 KiB
packaging ------------------------------ 64.91 KiB/64.91 KiB
text-unidecode ------------------------------ 76.32 KiB/76.32 KiB
click ------------------------------ 99.76 KiB/99.76 KiB
flask ------------------------------ 78.88 KiB/100.88 KiB
urllib3 ------------------------------ 78.64 KiB/125.66 KiB
jinja2 ------------------------------ 62.88 KiB/131.74 KiB
charset-normalizer ------------------------------ 128.00 KiB/145.08 KiB
certifi ------------------------------ 155.88 KiB/155.88 KiB
werkzeug ------------------------------ 93.06 KiB/219.24 KiB
python-dateutil ------------------------------ 48.00 KiB/224.50 KiB
pytest ------------------------------ 77.57 KiB/335.58 KiB
greenlet ------------------------------ 63.58 KiB/589.71 KiB
pyright ------------------------------ 32.00 KiB/5.31 MiB
ruff ------------------------------ 190.91 KiB/11.02 MiB
duckdb ------------------------------ 93.61 KiB/19.27 MiB
playwright ------------------------------ 32.00 KiB/43.05 MiB
Building scubaduck @ file:///workspace/scubaduck
⠙ Preparing packages... (0/33)
pyee ------------------------------ 15.36 KiB/15.36 KiB
execnet ------------------------------ 30.88 KiB/39.66 KiB
pytest-xdist ------------------------------ 45.03 KiB/45.03 KiB
requests ------------------------------ 63.41 KiB/63.41 KiB
packaging ------------------------------ 64.91 KiB/64.91 KiB
text-unidecode ------------------------------ 76.32 KiB/76.32 KiB
click ------------------------------ 99.76 KiB/99.76 KiB
flask ------------------------------ 78.88 KiB/100.88 KiB
urllib3 ------------------------------ 78.64 KiB/125.66 KiB
jinja2 ------------------------------ 62.88 KiB/131.74 KiB
charset-normalizer ------------------------------ 128.00 KiB/145.08 KiB
certifi ------------------------------ 155.88 KiB/155.88 KiB
werkzeug ------------------------------ 93.06 KiB/219.24 KiB
python-dateutil ------------------------------ 48.00 KiB/224.50 KiB
pytest ------------------------------ 77.57 KiB/335.58 KiB
greenlet ------------------------------ 63.58 KiB/589.71 KiB
pyright ------------------------------ 32.00 KiB/5.31 MiB
ruff ------------------------------ 206.91 KiB/11.02 MiB
duckdb ------------------------------ 109.61 KiB/19.27 MiB
playwright ------------------------------ 32.00 KiB/43.05 MiB
Building scubaduck @ file:///workspace/scubaduck
⠙ Preparing packages... (0/33)
pyee ------------------------------ 15.36 KiB/15.36 KiB
execnet ------------------------------ 30.88 KiB/39.66 KiB
pytest-xdist ------------------------------ 45.03 KiB/45.03 KiB
requests ------------------------------ 63.41 KiB/63.41 KiB
packaging ------------------------------ 64.91 KiB/64.91 KiB
click ------------------------------ 99.76 KiB/99.76 KiB
flask ------------------------------ 78.88 KiB/100.88 KiB
urllib3 ------------------------------ 94.64 KiB/125.66 KiB
jinja2 ------------------------------ 75.21 KiB/131.74 KiB
charset-normalizer ------------------------------ 128.00 KiB/145.08 KiB
certifi ------------------------------ 155.88 KiB/155.88 KiB
werkzeug ------------------------------ 93.06 KiB/219.24 KiB
python-dateutil ------------------------------ 64.00 KiB/224.50 KiB
pytest ------------------------------ 77.57 KiB/335.58 KiB
greenlet ------------------------------ 63.58 KiB/589.71 KiB
pyright ------------------------------ 32.00 KiB/5.31 MiB
ruff ------------------------------ 206.91 KiB/11.02 MiB
duckdb ------------------------------ 109.61 KiB/19.27 MiB
playwright ------------------------------ 32.00 KiB/43.05 MiB
Building scubaduck @ file:///workspace/scubaduck
⠙ Preparing packages... (0/33)
pyee ------------------------------ 15.36 KiB/15.36 KiB
execnet ------------------------------ 30.88 KiB/39.66 KiB
pytest-xdist ------------------------------ 45.03 KiB/45.03 KiB
requests ------------------------------ 63.41 KiB/63.41 KiB
packaging ------------------------------ 64.91 KiB/64.91 KiB
flask ------------------------------ 78.88 KiB/100.88 KiB
urllib3 ------------------------------ 94.64 KiB/125.66 KiB
jinja2 ------------------------------ 91.21 KiB/131.74 KiB
charset-normalizer ------------------------------ 145.08 KiB/145.08 KiB
certifi ------------------------------ 155.88 KiB/155.88 KiB
werkzeug ------------------------------ 93.06 KiB/219.24 KiB
python-dateutil ------------------------------ 80.00 KiB/224.50 KiB
pytest ------------------------------ 109.57 KiB/335.58 KiB
greenlet ------------------------------ 79.58 KiB/589.71 KiB
pyright ------------------------------ 62.96 KiB/5.31 MiB
ruff ------------------------------ 238.91 KiB/11.02 MiB
duckdb ------------------------------ 141.61 KiB/19.27 MiB
playwright ------------------------------ 48.00 KiB/43.05 MiB
Building scubaduck @ file:///workspace/scubaduck
⠙ Preparing packages... (0/33)
pyee ------------------------------ 15.36 KiB/15.36 KiB
execnet ------------------------------ 30.88 KiB/39.66 KiB
pytest-xdist ------------------------------ 45.03 KiB/45.03 KiB
requests ------------------------------ 63.41 KiB/63.41 KiB
packaging ------------------------------ 64.91 KiB/64.91 KiB
flask ------------------------------ 78.88 KiB/100.88 KiB
urllib3 ------------------------------ 94.64 KiB/125.66 KiB
jinja2 ------------------------------ 91.21 KiB/131.74 KiB
charset-normalizer ------------------------------ 145.08 KiB/145.08 KiB
werkzeug ------------------------------ 93.06 KiB/219.24 KiB
python-dateutil ------------------------------ 80.00 KiB/224.50 KiB
pytest ------------------------------ 109.57 KiB/335.58 KiB
greenlet ------------------------------ 111.58 KiB/589.71 KiB
pyright ------------------------------ 110.96 KiB/5.31 MiB
ruff ------------------------------ 270.91 KiB/11.02 MiB
duckdb ------------------------------ 189.61 KiB/19.27 MiB
playwright ------------------------------ 48.00 KiB/43.05 MiB
Building scubaduck @ file:///workspace/scubaduck
⠙ Preparing packages... (0/33)
execnet ------------------------------ 39.66 KiB/39.66 KiB
pytest-xdist ------------------------------ 45.03 KiB/45.03 KiB
requests ------------------------------ 63.41 KiB/63.41 KiB
packaging ------------------------------ 64.91 KiB/64.91 KiB
flask ------------------------------ 94.88 KiB/100.88 KiB
urllib3 ------------------------------ 94.64 KiB/125.66 KiB
jinja2 ------------------------------ 91.21 KiB/131.74 KiB
charset-normalizer ------------------------------ 145.08 KiB/145.08 KiB
werkzeug ------------------------------ 109.06 KiB/219.24 KiB
python-dateutil ------------------------------ 125.45 KiB/224.50 KiB
pytest ------------------------------ 125.57 KiB/335.58 KiB
greenlet ------------------------------ 143.58 KiB/589.71 KiB
pyright ------------------------------ 142.96 KiB/5.31 MiB
ruff ------------------------------ 318.91 KiB/11.02 MiB
duckdb ------------------------------ 221.61 KiB/19.27 MiB
playwright ------------------------------ 48.00 KiB/43.05 MiB
Building scubaduck @ file:///workspace/scubaduck
⠙ Preparing packages... (0/33)
execnet ------------------------------ 39.66 KiB/39.66 KiB
pytest-xdist ------------------------------ 45.03 KiB/45.03 KiB
requests ------------------------------ 63.41 KiB/63.41 KiB
flask ------------------------------ 94.88 KiB/100.88 KiB
urllib3 ------------------------------ 94.64 KiB/125.66 KiB
jinja2 ------------------------------ 91.21 KiB/131.74 KiB
charset-normalizer ------------------------------ 145.08 KiB/145.08 KiB
werkzeug ------------------------------ 109.06 KiB/219.24 KiB
python-dateutil ------------------------------ 141.45 KiB/224.50 KiB
pytest ------------------------------ 125.57 KiB/335.58 KiB
greenlet ------------------------------ 159.58 KiB/589.71 KiB
pyright ------------------------------ 158.96 KiB/5.31 MiB
ruff ------------------------------ 334.91 KiB/11.02 MiB
duckdb ------------------------------ 237.61 KiB/19.27 MiB
playwright ------------------------------ 48.00 KiB/43.05 MiB
Building scubaduck @ file:///workspace/scubaduck
⠙ Preparing packages... (0/33)
execnet ------------------------------ 39.66 KiB/39.66 KiB
pytest-xdist ------------------------------ 45.03 KiB/45.03 KiB
flask ------------------------------ 94.88 KiB/100.88 KiB
urllib3 ------------------------------ 94.64 KiB/125.66 KiB
jinja2 ------------------------------ 107.21 KiB/131.74 KiB
charset-normalizer ------------------------------ 145.08 KiB/145.08 KiB
werkzeug ------------------------------ 109.06 KiB/219.24 KiB
python-dateutil ------------------------------ 157.45 KiB/224.50 KiB
pytest ------------------------------ 125.57 KiB/335.58 KiB
greenlet ------------------------------ 175.58 KiB/589.71 KiB
pyright ------------------------------ 174.96 KiB/5.31 MiB
ruff ------------------------------ 350.91 KiB/11.02 MiB
duckdb ------------------------------ 253.61 KiB/19.27 MiB
playwright ------------------------------ 48.00 KiB/43.05 MiB
Building scubaduck @ file:///workspace/scubaduck
⠙ Preparing packages... (0/33)
execnet ------------------------------ 39.66 KiB/39.66 KiB
flask ------------------------------ 100.88 KiB/100.88 KiB
urllib3 ------------------------------ 94.64 KiB/125.66 KiB
jinja2 ------------------------------ 107.21 KiB/131.74 KiB
charset-normalizer ------------------------------ 145.08 KiB/145.08 KiB
werkzeug ------------------------------ 109.06 KiB/219.24 KiB
python-dateutil ------------------------------ 189.45 KiB/224.50 KiB
pytest ------------------------------ 125.57 KiB/335.58 KiB
greenlet ------------------------------ 191.58 KiB/589.71 KiB
pyright ------------------------------ 206.96 KiB/5.31 MiB
ruff ------------------------------ 382.91 KiB/11.02 MiB
duckdb ------------------------------ 285.61 KiB/19.27 MiB
playwright ------------------------------ 48.00 KiB/43.05 MiB
Building scubaduck @ file:///workspace/scubaduck
⠙ Preparing packages... (0/33)
execnet ------------------------------ 39.66 KiB/39.66 KiB
flask ------------------------------ 100.88 KiB/100.88 KiB
urllib3 ------------------------------ 94.64 KiB/125.66 KiB
jinja2 ------------------------------ 123.21 KiB/131.74 KiB
werkzeug ------------------------------ 125.06 KiB/219.24 KiB
python-dateutil ------------------------------ 221.45 KiB/224.50 KiB
pytest ------------------------------ 141.57 KiB/335.58 KiB
greenlet ------------------------------ 255.58 KiB/589.71 KiB
pyright ------------------------------ 254.96 KiB/5.31 MiB
ruff ------------------------------ 430.91 KiB/11.02 MiB
duckdb ------------------------------ 333.61 KiB/19.27 MiB
playwright ------------------------------ 48.00 KiB/43.05 MiB
Building scubaduck @ file:///workspace/scubaduck
⠙ Preparing packages... (0/33)
execnet ------------------------------ 39.66 KiB/39.66 KiB
flask ------------------------------ 100.88 KiB/100.88 KiB
urllib3 ------------------------------ 110.64 KiB/125.66 KiB
jinja2 ------------------------------ 123.21 KiB/131.74 KiB
werkzeug ------------------------------ 125.06 KiB/219.24 KiB
python-dateutil ------------------------------ 221.45 KiB/224.50 KiB
pytest ------------------------------ 173.57 KiB/335.58 KiB
greenlet ------------------------------ 303.58 KiB/589.71 KiB
pyright ------------------------------ 302.96 KiB/5.31 MiB
ruff ------------------------------ 462.91 KiB/11.02 MiB
duckdb ------------------------------ 365.61 KiB/19.27 MiB
playwright ------------------------------ 64.00 KiB/43.05 MiB
Building scubaduck @ file:///workspace/scubaduck
⠹ Preparing packages... (20/33)
execnet ------------------------------ 39.66 KiB/39.66 KiB
urllib3 ------------------------------ 110.64 KiB/125.66 KiB
jinja2 ------------------------------ 131.74 KiB/131.74 KiB
werkzeug ------------------------------ 141.06 KiB/219.24 KiB
python-dateutil ------------------------------ 221.45 KiB/224.50 KiB
pytest ------------------------------ 173.57 KiB/335.58 KiB
greenlet ------------------------------ 351.58 KiB/589.71 KiB
pyright ------------------------------ 350.96 KiB/5.31 MiB
ruff ------------------------------ 526.91 KiB/11.02 MiB
duckdb ------------------------------ 445.61 KiB/19.27 MiB
playwright ------------------------------ 64.00 KiB/43.05 MiB
Building scubaduck @ file:///workspace/scubaduck
⠹ Preparing packages... (20/33)
urllib3 ------------------------------ 110.64 KiB/125.66 KiB
jinja2 ------------------------------ 131.74 KiB/131.74 KiB
werkzeug ------------------------------ 141.06 KiB/219.24 KiB
python-dateutil ------------------------------ 221.45 KiB/224.50 KiB
pytest ------------------------------ 189.57 KiB/335.58 KiB
greenlet ------------------------------ 367.58 KiB/589.71 KiB
pyright ------------------------------ 382.96 KiB/5.31 MiB
ruff ------------------------------ 558.91 KiB/11.02 MiB
duckdb ------------------------------ 461.61 KiB/19.27 MiB
playwright ------------------------------ 64.00 KiB/43.05 MiB
Building scubaduck @ file:///workspace/scubaduck
⠹ Preparing packages... (20/33)
urllib3 ------------------------------ 125.66 KiB/125.66 KiB
jinja2 ------------------------------ 131.74 KiB/131.74 KiB
werkzeug ------------------------------ 141.06 KiB/219.24 KiB
pytest ------------------------------ 189.57 KiB/335.58 KiB
greenlet ------------------------------ 463.58 KiB/589.71 KiB
pyright ------------------------------ 462.96 KiB/5.31 MiB
ruff ------------------------------ 638.91 KiB/11.02 MiB
duckdb ------------------------------ 541.61 KiB/19.27 MiB
playwright ------------------------------ 78.19 KiB/43.05 MiB
Building scubaduck @ file:///workspace/scubaduck
⠹ Preparing packages... (20/33)
urllib3 ------------------------------ 125.66 KiB/125.66 KiB
werkzeug ------------------------------ 141.06 KiB/219.24 KiB
pytest ------------------------------ 189.57 KiB/335.58 KiB
greenlet ------------------------------ 463.58 KiB/589.71 KiB
pyright ------------------------------ 526.96 KiB/5.31 MiB
ruff ------------------------------ 702.91 KiB/11.02 MiB
duckdb ------------------------------ 589.61 KiB/19.27 MiB
playwright ------------------------------ 78.19 KiB/43.05 MiB
Building scubaduck @ file:///workspace/scubaduck
⠹ Preparing packages... (20/33)
werkzeug ------------------------------ 141.06 KiB/219.24 KiB
pytest ------------------------------ 205.57 KiB/335.58 KiB
greenlet ------------------------------ 463.58 KiB/589.71 KiB
pyright ------------------------------ 606.96 KiB/5.31 MiB
ruff ------------------------------ 782.91 KiB/11.02 MiB
duckdb ------------------------------ 685.61 KiB/19.27 MiB
playwright ------------------------------ 94.19 KiB/43.05 MiB
Building scubaduck @ file:///workspace/scubaduck
⠹ Preparing packages... (20/33)
werkzeug ------------------------------ 219.24 KiB/219.24 KiB
pytest ------------------------------ 285.57 KiB/335.58 KiB
greenlet ------------------------------ 495.58 KiB/589.71 KiB
pyright ------------------------------ 1.12 MiB/5.31 MiB
ruff ------------------------------ 1.31 MiB/11.02 MiB
duckdb ------------------------------ 1.22 MiB/19.27 MiB
playwright ------------------------------ 174.19 KiB/43.05 MiB
Building scubaduck @ file:///workspace/scubaduck
⠹ Preparing packages... (20/33)
pytest ------------------------------ 317.57 KiB/335.58 KiB
greenlet ------------------------------ 495.58 KiB/589.71 KiB
pyright ------------------------------ 1.26 MiB/5.31 MiB
ruff ------------------------------ 1.45 MiB/11.02 MiB
duckdb ------------------------------ 1.36 MiB/19.27 MiB
playwright ------------------------------ 254.19 KiB/43.05 MiB
Building scubaduck @ file:///workspace/scubaduck
⠹ Preparing packages... (20/33)
greenlet ------------------------------ 543.58 KiB/589.71 KiB
pyright ------------------------------ 1.56 MiB/5.31 MiB
ruff ------------------------------ 1.89 MiB/11.02 MiB
duckdb ------------------------------ 1.78 MiB/19.27 MiB
playwright ------------------------------ 702.19 KiB/43.05 MiB
Building scubaduck @ file:///workspace/scubaduck
⠹ Preparing packages... (20/33)
greenlet ------------------------------ 575.58 KiB/589.71 KiB
pyright ------------------------------ 1.79 MiB/5.31 MiB
ruff ------------------------------ 2.55 MiB/11.02 MiB
duckdb ------------------------------ 2.44 MiB/19.27 MiB
playwright ------------------------------ 1.31 MiB/43.05 MiB
Building scubaduck @ file:///workspace/scubaduck
⠹ Preparing packages... (20/33)
pyright ------------------------------ 1.81 MiB/5.31 MiB
ruff ------------------------------ 2.94 MiB/11.02 MiB
duckdb ------------------------------ 2.81 MiB/19.27 MiB
playwright ------------------------------ 1.72 MiB/43.05 MiB
Building scubaduck @ file:///workspace/scubaduck
⠹ Preparing packages... (20/33)
pyright ------------------------------ 1.84 MiB/5.31 MiB
ruff ------------------------------ 3.97 MiB/11.02 MiB
duckdb ------------------------------ 3.84 MiB/19.27 MiB
playwright ------------------------------ 2.78 MiB/43.05 MiB
Building scubaduck @ file:///workspace/scubaduck
⠹ Preparing packages... (20/33)
pyright ------------------------------ 1.92 MiB/5.31 MiB
ruff ------------------------------ 5.41 MiB/11.02 MiB
duckdb ------------------------------ 5.28 MiB/19.27 MiB
playwright ------------------------------ 4.20 MiB/43.05 MiB
Building scubaduck @ file:///workspace/scubaduck
⠸ Preparing packages... (28/33)
pyright ------------------------------ 1.98 MiB/5.31 MiB
ruff ------------------------------ 6.83 MiB/11.02 MiB
duckdb ------------------------------ 6.69 MiB/19.27 MiB
playwright ------------------------------ 5.59 MiB/43.05 MiB
Building scubaduck @ file:///workspace/scubaduck
⠸ Preparing packages... (28/33)
pyright ------------------------------ 2.07 MiB/5.31 MiB
ruff ------------------------------ 8.42 MiB/11.02 MiB
duckdb ------------------------------ 8.29 MiB/19.27 MiB
playwright ------------------------------ 7.25 MiB/43.05 MiB
Building scubaduck @ file:///workspace/scubaduck
⠸ Preparing packages... (28/33)
pyright ------------------------------ 2.13 MiB/5.31 MiB
ruff ------------------------------ 10.00 MiB/11.02 MiB
duckdb ------------------------------ 9.90 MiB/19.27 MiB
playwright ------------------------------ 8.83 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.95 MiB/43.05 MiB
Building scubaduck @ file:///workspace/scubaduck
⠸ Preparing packages... (28/33)
pyright ------------------------------ 2.14 MiB/5.31 MiB
duckdb ------------------------------ 11.40 MiB/19.27 MiB
playwright ------------------------------ 10.41 MiB/43.05 MiB
Building scubaduck @ file:///workspace/scubaduck
⠼ Preparing packages... (29/33)
pyright ------------------------------ 2.19 MiB/5.31 MiB
duckdb ------------------------------ 13.89 MiB/19.27 MiB
playwright ------------------------------ 12.94 MiB/43.05 MiB
Building scubaduck @ file:///workspace/scubaduck
⠼ Preparing packages... (29/33)
pyright ------------------------------ 2.24 MiB/5.31 MiB
duckdb ------------------------------ 16.31 MiB/19.27 MiB
playwright ------------------------------ 15.36 MiB/43.05 MiB
Built scubaduck @ file:///workspace/scubaduck
⠼ Preparing packages... (29/33)
pyright ------------------------------ 2.25 MiB/5.31 MiB
duckdb ------------------------------ 18.23 MiB/19.27 MiB
playwright ------------------------------ 17.20 MiB/43.05 MiB
⠼ Preparing packages... (29/33)
pyright ------------------------------ 2.27 MiB/5.31 MiB
duckdb ------------------------------ 18.48 MiB/19.27 MiB
playwright ------------------------------ 17.50 MiB/43.05 MiB
⠼ Preparing packages... (29/33)
pyright ------------------------------ 2.36 MiB/5.31 MiB
playwright ------------------------------ 19.83 MiB/43.05 MiB
⠼ Preparing packages... (29/33)
pyright ------------------------------ 2.36 MiB/5.31 MiB
playwright ------------------------------ 20.78 MiB/43.05 MiB
⠴ Preparing packages... (31/33)
pyright ------------------------------ 2.44 MiB/5.31 MiB
playwright ------------------------------ 25.08 MiB/43.05 MiB
⠴ Preparing packages... (31/33)
pyright ------------------------------ 2.61 MiB/5.31 MiB
playwright ------------------------------ 27.08 MiB/43.05 MiB
⠴ Preparing packages... (31/33)
pyright ------------------------------ 2.73 MiB/5.31 MiB
playwright ------------------------------ 28.62 MiB/43.05 MiB
⠴ Preparing packages... (31/33)
pyright ------------------------------ 2.86 MiB/5.31 MiB
playwright ------------------------------ 31.39 MiB/43.05 MiB
⠦ Preparing packages... (31/33)
pyright ------------------------------ 3.02 MiB/5.31 MiB
playwright ------------------------------ 34.62 MiB/43.05 MiB
⠦ Preparing packages... (31/33)
pyright ------------------------------ 3.15 MiB/5.31 MiB
playwright ------------------------------ 36.17 MiB/43.05 MiB
⠦ Preparing packages... (31/33)
pyright ------------------------------ 3.32 MiB/5.31 MiB
playwright ------------------------------ 37.09 MiB/43.05 MiB
⠦ Preparing packages... (31/33)
pyright ------------------------------ 3.54 MiB/5.31 MiB
playwright ------------------------------ 37.65 MiB/43.05 MiB
⠧ Preparing packages... (31/33)
pyright ------------------------------ 3.74 MiB/5.31 MiB
playwright ------------------------------ 39.50 MiB/43.05 MiB
⠧ Preparing packages... (31/33)
pyright ------------------------------ 4.06 MiB/5.31 MiB
playwright ------------------------------ 40.93 MiB/43.05 MiB
⠧ Preparing packages... (31/33)
pyright ------------------------------ 4.31 MiB/5.31 MiB
playwright ------------------------------ 42.20 MiB/43.05 MiB
⠧ Preparing packages... (31/33)
pyright ------------------------------ 4.36 MiB/5.31 MiB
⠇ Preparing packages... (32/33)
pyright ------------------------------ 4.48 MiB/5.31 MiB
⠇ Preparing packages... (32/33)
Prepared 33 packages in 1.43s
░░░░░░░░░░░░░░░░░░░░ [0/0] Installing wheels...
░░░░░░░░░░░░░░░░░░░░ [0/33] Installing wheels...
░░░░░░░░░░░░░░░░░░░░ [0/33] six==1.17.0
░░░░░░░░░░░░░░░░░░░░ [1/33] six==1.17.0
░░░░░░░░░░░░░░░░░░░░ [1/33] blinker==1.9.0
█░░░░░░░░░░░░░░░░░░░ [2/33] blinker==1.9.0
█░░░░░░░░░░░░░░░░░░░ [2/33] text-unidecode==1.3
█░░░░░░░░░░░░░░░░░░░ [3/33] text-unidecode==1.3
█░░░░░░░░░░░░░░░░░░░ [3/33] pluggy==1.6.0
██░░░░░░░░░░░░░░░░░░ [4/33] pluggy==1.6.0
██░░░░░░░░░░░░░░░░░░ [4/33] packaging==25.0
███░░░░░░░░░░░░░░░░░ [5/33] packaging==25.0
███░░░░░░░░░░░░░░░░░ [5/33] click==8.2.0
███░░░░░░░░░░░░░░░░░ [6/33] click==8.2.0
███░░░░░░░░░░░░░░░░░ [6/33] python-slugify==8.0.4
████░░░░░░░░░░░░░░░░ [7/33] python-slugify==8.0.4
████░░░░░░░░░░░░░░░░ [7/33] pytest-base-url==2.1.0
████░░░░░░░░░░░░░░░░ [8/33] pytest-base-url==2.1.0
████░░░░░░░░░░░░░░░░ [8/33] certifi==2025.4.26
█████░░░░░░░░░░░░░░░ [9/33] certifi==2025.4.26
███████████████████░ [32/33] pyright==1.1.400
Installed 33 packages in 80ms
+ 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/mBoEza-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% 31.8s167.7 MiB [] 0% 18.4s167.7 MiB [] 0% 12.3s167.7 MiB [] 0% 7.6s167.7 MiB [] 1% 4.7s167.7 MiB [] 3% 3.3s167.7 MiB [] 4% 2.7s167.7 MiB [] 5% 2.5s167.7 MiB [] 5% 2.4s167.7 MiB [] 7% 2.2s167.7 MiB [] 8% 2.0s167.7 MiB [] 10% 1.8s167.7 MiB [] 11% 1.6s167.7 MiB [] 13% 1.5s167.7 MiB [] 15% 1.4s167.7 MiB [] 16% 1.3s167.7 MiB [] 18% 1.3s167.7 MiB [] 20% 1.2s167.7 MiB [] 21% 1.2s167.7 MiB [] 23% 1.1s167.7 MiB [] 24% 1.1s167.7 MiB [] 25% 1.1s167.7 MiB [] 26% 1.1s167.7 MiB [] 28% 1.0s167.7 MiB [] 31% 1.0s167.7 MiB [] 32% 0.9s167.7 MiB [] 34% 0.9s167.7 MiB [] 36% 0.8s167.7 MiB [] 38% 0.8s167.7 MiB [] 39% 0.8s167.7 MiB [] 42% 0.7s167.7 MiB [] 44% 0.7s167.7 MiB [] 46% 0.6s167.7 MiB [] 48% 0.6s167.7 MiB [] 50% 0.6s167.7 MiB [] 51% 0.6s167.7 MiB [] 52% 0.6s167.7 MiB [] 53% 0.6s167.7 MiB [] 54% 0.6s167.7 MiB [] 55% 0.6s167.7 MiB [] 57% 0.6s167.7 MiB [] 58% 0.6s167.7 MiB [] 59% 0.6s167.7 MiB [] 60% 0.6s167.7 MiB [] 63% 0.6s167.7 MiB [] 64% 0.6s167.7 MiB [] 66% 0.5s167.7 MiB [] 67% 0.5s167.7 MiB [] 69% 0.5s167.7 MiB [] 70% 0.4s167.7 MiB [] 72% 0.4s167.7 MiB [] 73% 0.4s167.7 MiB [] 74% 0.4s167.7 MiB [] 76% 0.4s167.7 MiB [] 78% 0.3s167.7 MiB [] 80% 0.3s167.7 MiB [] 81% 0.3s167.7 MiB [] 82% 0.3s167.7 MiB [] 84% 0.2s167.7 MiB [] 85% 0.2s167.7 MiB [] 87% 0.2s167.7 MiB [] 89% 0.2s167.7 MiB [] 90% 0.1s167.7 MiB [] 91% 0.1s167.7 MiB [] 92% 0.1s167.7 MiB [] 94% 0.1s167.7 MiB [] 96% 0.1s167.7 MiB [] 97% 0.0s167.7 MiB [] 98% 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 [] 18% 0.1s2.3 MiB [] 49% 0.1s2.3 MiB [] 79% 0.0s2.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.6s101.4 MiB [] 0% 11.6s101.4 MiB [] 0% 7.1s101.4 MiB [] 1% 4.3s101.4 MiB [] 3% 2.5s101.4 MiB [] 6% 1.5s101.4 MiB [] 9% 1.2s101.4 MiB [] 10% 1.1s101.4 MiB [] 13% 0.9s101.4 MiB [] 14% 1.0s101.4 MiB [] 14% 1.1s101.4 MiB [] 16% 1.1s101.4 MiB [] 19% 1.0s101.4 MiB [] 20% 0.9s101.4 MiB [] 24% 0.8s101.4 MiB [] 26% 0.8s101.4 MiB [] 28% 0.7s101.4 MiB [] 30% 0.7s101.4 MiB [] 32% 0.7s101.4 MiB [] 34% 0.7s101.4 MiB [] 35% 0.7s101.4 MiB [] 39% 0.6s101.4 MiB [] 42% 0.6s101.4 MiB [] 46% 0.5s101.4 MiB [] 50% 0.4s101.4 MiB [] 55% 0.4s101.4 MiB [] 59% 0.3s101.4 MiB [] 61% 0.3s101.4 MiB [] 65% 0.3s101.4 MiB [] 67% 0.3s101.4 MiB [] 68% 0.3s101.4 MiB [] 69% 0.2s101.4 MiB [] 70% 0.2s101.4 MiB [] 73% 0.2s101.4 MiB [] 75% 0.2s101.4 MiB [] 77% 0.2s101.4 MiB [] 78% 0.2s101.4 MiB [] 83% 0.1s101.4 MiB [] 85% 0.1s101.4 MiB [] 89% 0.1s101.4 MiB [] 93% 0.1s101.4 MiB [] 95% 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 check the repository's root directory for any AGENTS.md instructions. Let's take a look.
bash: .venv/bin/activate: No such file or directory
root@09b91c3ec8d3:/workspace# ls
scubaduck
I see a "scubaduck" directory, which probably indicates the repo root.
root@09b91c3ec8d3:/workspace# cd scubaduck
root@09b91c3ec8d3:/workspace/scubaduck# ls
AGENTS.md codex_setup.sh scubaduck tests
README.md pyproject.toml stubs uv.lock
I'll review AGENTS.md at the root to understand the instructions.
root@09b91c3ec8d3:/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
Since interactive editors aren't an option, I'll check the README or other documents.
root@09b91c3ec8d3:/workspace/scubaduck# ls
AGENTS.md codex_setup.sh scubaduck tests
README.md pyproject.toml stubs uv.lock
root@09b91c3ec8d3:/workspace/scubaduck# cat README.md | head -n 20
I really like Scuba (Meta's internal real-time database system). The distributed
, real-time database part of Scuba is quite difficult (and expensive) to replica
te, but I also really like Scuba's UI for doing queries, and I have found myself
wishing that I have access to it even for "small" databases, e.g., I have a sql
ite dataset I want to explore.
Pivotal ideas:
* Time series by default. In the dedicated "time series" view, there are many fe
atures specifically oriented towards working towards tables that represent event
s that occurred over time: the start, end, compare, aggregate and granularity fi
elds all specially privilege the timestamp field. In fact, you can't log events
to Scuba's backing data store without a timestamp, they always come with one. (S
cuba also supports other views that don't presuppose a time series, but the time
series is the most beloved and well used view.) This is in contrast to typical
software which tries to generalize to arbitrary data first, with time series bei
ng added on later.
* It's all about exploration. Scuba is predicated on the idea that you don't kno
w what you're looking for, that you are going to spend time tweaking queries and
changing filters/grouping as part of an investigation to figure out why a syste
m behaves the way it is. So the filters/comparisons/groupings you want to edit a
re always visible on the left sidebar, with the expectation that you're going to
tweak the query to look at something else. Similarly, all the parameters of you
r query get saved into your URL, so your browser history can double up as a quer
y history / you can easily share a query with someone else. This is contrast to
typical software which is often oriented to making pretty dashboards and reports
. (This function is important too, but it's not what I want in exploration mode!
)
* You can fix data problems in the query editor. It's pretty common to have mess
ed up and ended up with a database that doesn't have exactly the columns you nee
d, or some columns that are corrupted in some way. Scuba has pretty robust suppo
rt for defining custom columns with arbitrary SQL functions, grouping over them
as if they were native functions, and doing so with minimal runtime cost (Scuba
aims to turn around your query in milliseconds!) Having to go and run a huge dat
a pipeline to fix your data is a big impediment to exploration; quick and easy c
ustom columns means you can patch over problems when you're investigating and fi
x them for real later.
We're going to build a exploratory data analysis tool like Scuba for time series
database (i.e., a database with a mandatory timestamp representing the time an
event occurred). We'll use DuckDB as the underlying SQL engine served from a Py
thon server, and render the GUI/results as a webpage with vanilla HTML and JS. W
e'll use choices.js to support token inputs. We define a token input to mean a
text input element where as you type a dropdown displays with valid values, and
if you select one or press enter, the selection turns into a token/chip that can
only be deleted as one unit.
To start, we are going to support one views: samples. The samples view only all
ows you to view individual samples from the database, subject to a filter. Our m
ain UI concept is that there is a left sidebar that is the query editor, and the
right side that shows the view. The sidebar is always visible and defaults to
the query parameters of the current view. After you make changes to the query,
clicking the "Dive" button updates the view. The URL of the page encodes all of
the values of the query (and gets updated when you Dive), so the browser's back
button lets you view previous queries.
The query editor's job is to generate a SQL query, which then is applied on the
database, and then the result visualized according to the view.
Here are the settings you can apply to the query. The help text should show up w
hen you mouse over the field name:
* Start/End - Help text: "Sets the start/end of the time range to query. Can be
any kind of datetime string. For example: 'April 23, 2014' or 'yesterday'." The
UI for this selector supports both relative selections (now, -1 hour, -3 hours,
-12 hours, -1 day, -3 days, -1 week, -1 fortnight, -30 days, -90 days) as well a
s specifying an absolute date. The way this field is rendered is there is a fre
e form text box, a drop down arrow (for the relative selectors), and then a cale
ndar button (for date selection).
* Order By - Help text: "Choose a column to sort results by." There is an ASC/D
ESC toggle next to it.
The README describes a database tool, but I'll focus on modifying the time series chart.
root@09b91c3ec8d3:/workspace/scubaduck# ls scubaduck
__init__.py sample.csv server.py static
root@09b91c3ec8d3:/workspace/scubaduck# ls scubaduck/static
index.html js
root@09b91c3ec8d3:/workspace/scubaduck# ls scubaduck/static/js
chip_input.js timeseries_chart.js
I'm opening the timeseries_chart.js to explore its content.
root@09b91c3ec8d3:/workspace/scubaduck# cat scubaduck/static/js/timeseries_chart
.js | head -n 50
let resizeObserver = null;
let currentChart = null;
function showTimeSeries(data) {
function parseTs(s) {
if (s.match(/GMT/) || s.endsWith('Z') || /\+\d{2}:?\d{2}$/.test(s)) {
return new Date(s).getTime();
}
return new Date(s + 'Z').getTime();
}
const view = document.getElementById('view');
if (data.rows.length === 0) {
view.innerHTML = '<p id="empty-message">Empty data provided to table</p>';
return;
}
const height = 600;
view.innerHTML =
'<div id="ts-container"><div id="legend"></div><div id="chart-wrapper"><svg
id="chart" height="' +
height +
'"></svg></div></div>';
const svg = document.getElementById('chart');
const legend = document.getElementById('legend');
const crosshairLine = document.createElementNS('http://www.w3.org/2000/svg', '
line');
crosshairLine.id = 'crosshair_line';
crosshairLine.setAttribute('stroke', '#555');
crosshairLine.style.display = 'none';
const crosshairDots = document.createElementNS('http://www.w3.org/2000/svg', '
g');
crosshairDots.id = 'crosshair_dots';
crosshairDots.style.display = 'none';
const groups = groupBy.chips || [];
const hasHits = document.getElementById('show_hits').checked ? 1 : 0;
const fill = document.getElementById('fill').value;
const bucketMs = (data.bucket_size || 3600) * 1000;
const start = data.start ? parseTs(data.start) : null;
const end = data.end ? parseTs(data.end) : null;
const startIdx = 1 + groups.length + hasHits;
const valueCols = selectedColumns.slice(groups.length + hasHits);
const series = {};
data.rows.forEach(r => {
const ts = parseTs(r[0]);
const groupKey = groups.map((_, i) => r[1 + i]).join(':') || 'all';
valueCols.forEach((name, i) => {
const val = Number(r[startIdx + i]);
const key = groupKey === 'all' ? name : groupKey + ':' + name;
if (!series[key]) series[key] = {};
series[key][ts] = val;
});
});
root@09b91c3ec8d3:/workspace/scubaduck# cat scubaduck/static/js/timeseries_chart
.js | sed -n '51,150p'
const buckets = [];
let minX = start !== null ? start : Infinity;
let maxX = end !== null ? end : -Infinity;
if (start !== null && end !== null) {
for (let t = start; t <= end; t += bucketMs) {
buckets.push(t);
}
} else {
Object.keys(series).forEach(k => {
const s = series[k];
Object.keys(s).forEach(t => {
const n = Number(t);
if (n < minX) minX = n;
if (n > maxX) maxX = n;
});
});
for (let t = minX; t <= maxX; t += bucketMs) {
buckets.push(t);
}
}
let minY = Infinity,
maxY = -Infinity;
Object.keys(series).forEach(key => {
const vals = series[key];
buckets.forEach(b => {
const v = vals[b];
const val = v === undefined && fill === '0' ? 0 : v;
if (val === undefined) return;
if (val < minY) minY = val;
if (val > maxY) maxY = val;
});
});
if (fill === '0') {
if (minY > 0) minY = 0;
if (maxY < 0) maxY = 0;
}
const colors = [
'#1f77b4',
'#ff7f0e',
'#2ca02c',
'#d62728',
'#9467bd',
'#8c564b',
'#e377c2'
];
currentChart = {
svg,
legend,
series,
buckets,
minX,
maxX,
minY,
maxY,
fill,
colors,
height,
crosshairLine,
crosshairDots,
seriesEls: {},
bucketPixels: [],
xScale: null,
yScale: null,
selected: null
};
const intervals = [
{unit: 'second', step: 1, ms: 1000},
{unit: 'second', step: 2, ms: 2000},
{unit: 'second', step: 5, ms: 5000},
{unit: 'second', step: 10, ms: 10000},
{unit: 'second', step: 15, ms: 15000},
{unit: 'second', step: 30, ms: 30000},
{unit: 'minute', step: 1, ms: 60000},
{unit: 'minute', step: 2, ms: 120000},
{unit: 'minute', step: 5, ms: 300000},
{unit: 'minute', step: 10, ms: 600000},
{unit: 'minute', step: 15, ms: 900000},
{unit: 'minute', step: 30, ms: 1800000},
{unit: 'hour', step: 1, ms: 3600000},
{unit: 'hour', step: 2, ms: 7200000},
{unit: 'hour', step: 3, ms: 10800000},
{unit: 'hour', step: 4, ms: 14400000},
{unit: 'hour', step: 6, ms: 21600000},
{unit: 'hour', step: 12, ms: 43200000},
{unit: 'day', step: 1, ms: 86400000},
{unit: 'day', step: 2, ms: 172800000},
{unit: 'week', step: 1, ms: 604800000},
{unit: 'week', step: 2, ms: 1209600000},
{unit: 'month', step: 1},
{unit: 'month', step: 3},
{unit: 'month', step: 6},
{unit: 'year', step: 1},
{unit: 'year', step: 2},
{unit: 'year', step: 5},
{unit: 'year', step: 10}
];
root@09b91c3ec8d3:/workspace/scubaduck# cat scubaduck/static/js/timeseries_chart
.js | sed -n '151,300p'
function chooseInterval(start, end) {
const span = end - start;
function approxMs(i) {
if (i.ms) return i.ms;
if (i.unit === 'month') return i.step * 2629800000;
if (i.unit === 'year') return i.step * 31557600000;
return 1000;
}
let best = intervals[0];
let bestScore = Infinity;
intervals.forEach(i => {
const count = span / approxMs(i);
const score = Math.abs(count - 15);
if (score < bestScore) {
best = i;
bestScore = score;
}
});
return best;
}
function generateTicks(start, end, intv) {
const ticks = [];
if (intv.unit === 'month' || intv.unit === 'year') {
let d = new Date(start);
d.setUTCDate(1);
if (intv.unit === 'year') d.setUTCMonth(0);
let unitVal =
intv.unit === 'month'
? d.getUTCFullYear() * 12 + d.getUTCMonth()
: d.getUTCFullYear();
unitVal = Math.ceil(unitVal / intv.step) * intv.step;
while (true) {
const year =
intv.unit === 'month' ? Math.floor(unitVal / 12) : unitVal;
const month = intv.unit === 'month' ? unitVal % 12 : 0;
const t = Date.UTC(year, month, 1);
if (t > end) break;
if (t >= start) ticks.push(t);
unitVal += intv.step;
}
} else {
const step = intv.ms * intv.step;
let t = Math.ceil(start / step) * step;
if (intv.unit === 'week') {
const d = new Date(t);
const adj = (d.getUTCDay() + 6) % 7;
t = d.getTime() - adj * 86400000;
t = Math.ceil(t / step) * step;
}
if (t === start) t += step;
for (; t <= end; t += step) ticks.push(t);
}
return ticks;
}
function labelUnit(intv) {
if (intv.unit === 'year') return 'year';
if (intv.unit === 'month') return 'month';
if (intv.unit === 'day' || intv.unit === 'week') return 'day';
if (intv.unit === 'hour') return 'hour';
return 'minute';
}
function fmt(date, unit) {
const pad = n => String(n).padStart(2, '0');
const mon = date.toLocaleString('en-US', {month: 'short'});
switch (unit) {
case 'year':
return String(date.getFullYear());
case 'month':
if (date.getMonth() === 0) return String(date.getFullYear());
return `${mon} ${date.getFullYear()}`;
case 'day':
if (date.getDate() === 1) return `${mon} ${date.getFullYear()}`;
return `${date.getDate()} ${mon}`;
case 'hour':
if (date.getHours() === 0 && date.getMinutes() === 0)
return `${date.getDate()} ${mon}`;
return `${pad(date.getHours())}:${pad(date.getMinutes())}`;
default:
if (date.getMinutes() === 0 && date.getSeconds() === 0)
return `${pad(date.getHours())}:${pad(date.getMinutes())}`;
return `${pad(date.getMinutes())}:${pad(date.getSeconds())}`;
}
}
function render() {
const style = getComputedStyle(svg.parentElement);
const width =
svg.parentElement.clientWidth -
parseFloat(style.paddingLeft) -
parseFloat(style.paddingRight);
svg.setAttribute('width', width);
svg.innerHTML = '';
legend.innerHTML = '';
let colorIndex = 0;
const xRange = maxX - minX || 1;
const yRange = maxY - minY || 1;
const xScale = x => ((x - minX) / xRange) * (width - 60) + 50;
const yScale = y => height - 30 - ((y - minY) / yRange) * (height - 60);
const seriesEls = {};
const agg = document.getElementById('aggregate').value.toLowerCase();
const groups = {};
Object.keys(series).forEach(key => {
const vals = series[key];
const color = colors[colorIndex++ % colors.length];
let path = '';
let drawing = false;
buckets.forEach(b => {
const v = vals[b];
if (v === undefined) {
if (fill === '0') {
const x = xScale(b);
const y = yScale(0);
path += (drawing ? 'L' : 'M') + x + ' ' + y + ' ';
drawing = true;
} else if (fill === 'blank') {
drawing = false;
}
// connect: do nothing
} else {
const x = xScale(b);
const y = yScale(v);
path += (drawing ? 'L' : 'M') + x + ' ' + y + ' ';
drawing = true;
}
});
const el = document.createElementNS('http://www.w3.org/2000/svg', 'path');
el.setAttribute('d', path.trim());
el.setAttribute('fill', 'none');
el.setAttribute('stroke', color);
el.setAttribute('stroke-width', '1.3');
svg.appendChild(el);
const idx = key.lastIndexOf(':');
const groupKey = idx === -1 ? 'all' : key.slice(0, idx);
const name = idx === -1 ? key : key.slice(idx + 1);
let group = groups[groupKey];
if (!group) {
const gEl = document.createElement('div');
gEl.className = 'legend-group';
const header = document.createElement('div');
header.className = 'legend-header';
header.textContent =
groupKey === 'all' ? agg : `${groupKey} ${agg}`;
gEl.appendChild(header);
const items = document.createElement('div');
items.className = 'legend-items';
gEl.appendChild(items);
root@09b91c3ec8d3:/workspace/scubaduck# cat scubaduck/static/js/timeseries_chart
.js | sed -n '301,600p'
legend.appendChild(gEl);
group = {items};
groups[groupKey] = group;
}
const item = document.createElement('div');
item.className = 'legend-item';
const label = document.createElement('span');
label.textContent = name;
label.style.color = color;
const valueSpan = document.createElement('span');
valueSpan.className = 'legend-value';
item.appendChild(label);
item.appendChild(valueSpan);
group.items.appendChild(item);
function highlight(on) {
el.setAttribute('stroke-width', on ? '2.5' : '1.3');
item.classList.toggle('highlight', on);
}
el.addEventListener('mouseenter', () => highlight(true));
el.addEventListener('mouseleave', () => highlight(false));
item.addEventListener('mouseenter', () => highlight(true));
item.addEventListener('mouseleave', () => highlight(false));
seriesEls[key] = { path: el, item, highlight, color, valueEl: valueSpan };
});
currentChart.seriesEls = seriesEls;
currentChart.xScale = xScale;
currentChart.yScale = yScale;
currentChart.bucketPixels = buckets.map(xScale);
svg.appendChild(crosshairLine);
svg.appendChild(crosshairDots);
const intv = chooseInterval(minX, maxX);
const ticks = generateTicks(minX, maxX, intv);
const lu = labelUnit(intv);
const rotate = ticks.length > 0 && (width - 60) / ticks.length < 60;
const axis = document.createElementNS('http://www.w3.org/2000/svg', 'g');
const axisLine = document.createElementNS('http://www.w3.org/2000/svg', 'lin
e');
axisLine.setAttribute('x1', xScale(minX));
axisLine.setAttribute('x2', xScale(maxX));
axisLine.setAttribute('y1', height - 30);
axisLine.setAttribute('y2', height - 30);
axisLine.setAttribute('stroke', '#888');
axis.appendChild(axisLine);
ticks.forEach(t => {
const x = xScale(t);
const line = document.createElementNS('http://www.w3.org/2000/svg', 'line'
);
line.setAttribute('x1', x);
line.setAttribute('y1', height - 30);
line.setAttribute('x2', x);
line.setAttribute('y2', height - 25);
line.setAttribute('stroke', '#888');
axis.appendChild(line);
const text = document.createElementNS('http://www.w3.org/2000/svg', 'text'
);
text.setAttribute('x', x);
text.setAttribute('y', height - 10);
text.setAttribute('text-anchor', 'middle');
text.setAttribute('class', 'tick-label' + (rotate ? ' rotated' : ''));
if (rotate) text.setAttribute('transform', `rotate(-45 ${x} ${height - 10}
)`);
text.textContent = fmt(new Date(t), lu);
axis.appendChild(text);
});
svg.appendChild(axis);
}
render();
function hideCrosshair() {
crosshairLine.style.display = 'none';
crosshairDots.style.display = 'none';
crosshairDots.innerHTML = '';
Object.values(currentChart.seriesEls).forEach(el => {
el.valueEl.textContent = '';
});
if (currentChart.selected) {
currentChart.seriesEls[currentChart.selected].highlight(false);
currentChart.selected = null;
}
}
svg.addEventListener('mouseleave', hideCrosshair);
svg.addEventListener('mousemove', e => {
const rect = svg.getBoundingClientRect();
const x = e.clientX - rect.left;
const y = e.clientY - rect.top;
const pixels = currentChart.bucketPixels;
if (!pixels.length) return;
let idx = 0;
let dist = Math.abs(pixels[0] - x);
for (let i = 1; i < pixels.length; i++) {
const d = Math.abs(pixels[i] - x);
if (d < dist) {
dist = d;
idx = i;
}
}
const bucket = currentChart.buckets[idx];
const xPix = pixels[idx];
crosshairLine.setAttribute('x1', xPix);
crosshairLine.setAttribute('x2', xPix);
crosshairLine.setAttribute('y1', currentChart.yScale(currentChart.maxY));
crosshairLine.setAttribute('y2', currentChart.yScale(currentChart.minY));
crosshairLine.style.display = 'block';
crosshairDots.style.display = 'block';
crosshairDots.innerHTML = '';
const options = [];
Object.keys(currentChart.series).forEach(key => {
const vals = currentChart.series[key];
let v = vals[bucket];
if (v === undefined && currentChart.fill !== '0') {
currentChart.seriesEls[key].valueEl.textContent = '';
return;
}
if (v === undefined) v = 0;
currentChart.seriesEls[key].valueEl.textContent = formatNumber(v);
const yPix = currentChart.yScale(v);
const dot = document.createElementNS('http://www.w3.org/2000/svg', 'circle
');
dot.setAttribute('cx', xPix);
dot.setAttribute('cy', yPix);
dot.setAttribute('r', '3');
dot.setAttribute('fill', currentChart.seriesEls[key].color);
crosshairDots.appendChild(dot);
options.push({ key, y: yPix });
});
if (options.length) {
let best = options[0];
let bestDist = Math.abs(best.y - y);
for (let i = 1; i < options.length; i++) {
const d = Math.abs(options[i].y - y);
if (d < bestDist) {
best = options[i];
bestDist = d;
}
}
if (currentChart.selected && currentChart.selected !== best.key) {
currentChart.seriesEls[currentChart.selected].highlight(false);
}
currentChart.seriesEls[best.key].highlight(true);
currentChart.selected = best.key;
}
});
if (resizeObserver) resizeObserver.disconnect();
resizeObserver = new ResizeObserver(render);
resizeObserver.observe(svg.parentElement);
}
I'll check the tests now to make sure they align with the crosshair freeze/unfreeze behavior.
root@09b91c3ec8d3:/workspace/scubaduck# ls tests
conftest.py test_server.py test_web.py
root@09b91c3ec8d3:/workspace/scubaduck# cat tests/test_server.py | head -n 20
from __future__ import annotations
import json
from pathlib import Path
from typing import cast
import duckdb
from scubaduck import server
import pytest
def test_basic_query() -> None:
app = server.app
client = app.test_client()
payload = {
"table": "events",
"start": "2024-01-01 00:00:00",
"end": "2024-01-02 00:00:00",
"order_by": "timestamp",
"order_dir": "ASC",
root@09b91c3ec8d3:/workspace/scubaduck# cat tests/test_web.py | head -n 20
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",
I’ll start exploring from the bottom.
root@09b91c3ec8d3:/workspace/scubaduck# sed -n '20,160p' tests/test_web.py
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_filter_remove_alignment(page: Any, server_url: str) -> None:
page.goto(server_url)
page.wait_for_selector("#order_by option", state="attached")
diff = page.evaluate(
"() => { const r=document.querySelector('#filters .filter-row').getBound
ingClientRect(); const x=document.querySelector('#filters .filter-row button.rem
ove').getBoundingClientRect(); return Math.abs(r.right - x.right); }"
)
assert diff <= 1
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")
I'm moving through the pages to find more relevant information.
root@09b91c3ec8d3:/workspace/scubaduck# sed -n '161,320p' tests/test_web.py
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"
)
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_graph_type_timeseries_fields(page: Any, server_url: str) -> None:
page.goto(server_url)
page.wait_for_selector("#graph_type", state="attached")
select_value(page, "#graph_type", "timeseries")
assert page.is_visible("#group_by_field")
assert page.is_visible("#aggregate_field")
assert page.is_visible("#x_axis_field")
assert page.is_visible("#granularity_field")
assert page.is_visible("#fill_field")
def test_timeseries_default_query(page: Any, server_url: str) -> None:
page.goto(server_url)
page.wait_for_selector("#graph_type", state="attached")
select_value(page, "#graph_type", "timeseries")
page.evaluate("window.lastResults = undefined")
page.click("text=Dive")
page.wait_for_function("window.lastResults !== undefined")
data = page.evaluate("window.lastResults")
assert "error" not in data
assert page.is_visible("#chart")
page.click("text=Columns")
assert not page.is_checked("#column_groups input[value='timestamp']")
def test_timeseries_single_bucket(page: Any, server_url: str) -> None:
page.goto(server_url)
page.wait_for_selector("#graph_type", state="attached")
page.fill("#start", "2024-01-01 00:00:00")
page.fill("#end", "2024-01-01 00:00:00")
select_value(page, "#graph_type", "timeseries")
page.evaluate("window.lastResults = undefined")
page.click("text=Dive")
page.wait_for_function("window.lastResults !== undefined")
path = page.get_attribute("#chart path", "d")
assert path is not None and "NaN" not in path
def test_timeseries_fill_options(page: Any, server_url: str) -> None:
page.goto(server_url)
page.wait_for_selector("#graph_type", state="attached")
page.fill("#start", "2024-01-01 00:00:00")
page.fill("#end", "2024-01-02 03:00:00")
select_value(page, "#graph_type", "timeseries")
select_value(page, "#granularity", "1 hour")
select_value(page, "#fill", "0")
page.evaluate("window.lastResults = undefined")
page.click("text=Dive")
page.wait_for_function("window.lastResults !== undefined")
path_zero = page.get_attribute("#chart path", "d")
assert path_zero is not None and path_zero.count("L") > 20
select_value(page, "#fill", "connect")
page.evaluate("window.lastResults = undefined")
page.click("text=Dive")
page.wait_for_function("window.lastResults !== undefined")
path_conn = page.get_attribute("#chart path", "d")
assert path_conn is not None and path_conn.count("M") == 1
select_value(page, "#fill", "blank")
page.evaluate("window.lastResults = undefined")
page.click("text=Dive")
page.wait_for_function("window.lastResults !== undefined")
path_blank = page.get_attribute("#chart path", "d")
assert path_blank is not None and path_blank.count("M") > 1
def test_timeseries_hover_highlight(page: Any, server_url: str) -> None:
page.goto(server_url)
page.wait_for_selector("#graph_type", state="attached")
select_value(page, "#graph_type", "timeseries")
page.evaluate("window.lastResults = undefined")
page.click("text=Dive")
page.wait_for_function("window.lastResults !== undefined")
page.wait_for_selector("#chart path", state="attached")
path_el = page.query_selector("#chart path")
assert path_el
page.evaluate(
"el => el.dispatchEvent(new MouseEvent('mouseenter', {bubbles: true}))",
path_el,
)
width = page.evaluate(
"getComputedStyle(document.querySelector('#chart path')).strokeWidth"
)
assert "2.5" in width
color = page.evaluate(
"getComputedStyle(document.querySelector('#legend .legend-item')).backgr
oundColor"
)
assert "221, 221, 221" in color
def test_timeseries_crosshair(page: Any, server_url: str) -> None:
page.goto(server_url)
page.wait_for_selector("#graph_type", state="attached")
select_value(page, "#graph_type", "timeseries")
page.evaluate("window.lastResults = undefined")
page.click("text=Dive")
page.wait_for_function("window.lastResults !== undefined")
page.wait_for_selector("#chart path", state="attached")
page.eval_on_selector(
"#chart",
"el => { const r = el.getBoundingClientRect(); el.dispatchEvent(new Mous
eEvent('mousemove', {clientX: r.left + r.width/2, clientY: r.top + r.height/2, b
ubbles: true})); }",
)
line_display = page.evaluate(
"document.getElementById('crosshair_line').style.display"
)
assert line_display != "none"
count = page.eval_on_selector_all("#crosshair_dots circle", "els => els.leng
th")
assert count > 0
page.eval_on_selector(
"#chart",
"el => el.dispatchEvent(new MouseEvent('mouseleave', {bubbles: true}))",
)
line_display = page.evaluate(
"document.getElementById('crosshair_line').style.display"
)
assert line_display == "none"
def test_timeseries_auto_timezone(browser: Any, server_url: str) -> None:
context = browser.new_context(timezone_id="America/New_York")
page = context.new_page()
page.goto(server_url)
page.wait_for_selector("#graph_type", state="attached")
select_value(page, "#graph_type", "timeseries")
page.evaluate("window.lastResults = undefined")
page.click("text=Dive")
page.wait_for_function("window.lastResults !== undefined")
path = page.get_attribute("#chart path", "d")
context.close()
assert path is not None
coords = [float(p.split(" ")[1]) for p in path.replace("M", "L").split("L")[
1:]]
name_inp = page.query_selector("#derived_list .derived .d-name")
assert name_inp
name_inp.fill("value_2")
expr.fill("value * 2")
page.click("text=View Settings")
page.fill("#start", "2024-01-01 00:00:00")
page.fill("#end", "2024-01-03 00:00:00")
select_value(page, "#granularity", "1 hour")
page.evaluate("window.lastResults = undefined")
page.click("text=Dive")
page.wait_for_function("window.lastResults !== undefined")
count = page.eval_on_selector_all("#chart path", "els => els.length")
assert count == 2
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_table_avg_group_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="timestamp",
group_by=["user"],
aggregate="Avg",
)
assert "error" not in data
assert len(data["rows"]) == 3
...
{"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")
inp.click()
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"
def test_chip_dropdown_hides_on_outside_click(page: Any, server_url: str) -> Non
e:
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.click("#header")
page.wait_for_selector("#filters .filter:last-child .chip-dropdown", state="
hidden")
def test_chip_input_no_outline(page: Any, server_url: str) -> None:
page.goto(server_url)
page.wait_for_selector("#order_by option", state="attached")
page.click("text=Add Filter")
inp = page.query_selector("#filters .filter:last-child .f-val")
assert inp
inp.click()
outline = page.evaluate(
"getComputedStyle(document.querySelector('#filters .filter:last-child .f
-val')).outlineStyle"
)
assert outline == "none"
def test_chip_enter_keeps_focus(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")
page.keyboard.type("alice")
I'll scroll near the bottom to double-check the necessary section for our change.
root@09b91c3ec8d3:/workspace/scubaduck# grep -n crosshair tests/test_web.py -n
280:def test_timeseries_crosshair(page: Any, server_url: str) -> None:
293: "document.getElementById('crosshair_line').style.display"
296: count = page.eval_on_selector_all("#crosshair_dots circle", "els => els.
length")
303: "document.getElementById('crosshair_line').style.display"
I'm looking for a time series click freeze test, maybe it doesn't exist yet.
root@09b91c3ec8d3:/workspace/scubaduck# grep -n freeze tests/test_web.py
I'll search through JS files to find how crosshair handling works before implementing freeze/unfreeze.
scubaduck/static/js/timeseries_chart.js:23: const crosshairLine = document.crea
teElementNS('http://www.w3.org/2000/svg', 'line');
scubaduck/static/js/timeseries_chart.js:24: crosshairLine.id = 'crosshair_line'
;
scubaduck/static/js/timeseries_chart.js:25: crosshairLine.setAttribute('stroke'
, '#555');
scubaduck/static/js/timeseries_chart.js:26: crosshairLine.style.display = 'none
';
scubaduck/static/js/timeseries_chart.js:28: const crosshairDots = document.crea
teElementNS('http://www.w3.org/2000/svg', 'g');
scubaduck/static/js/timeseries_chart.js:29: crosshairDots.id = 'crosshair_dots'
;
scubaduck/static/js/timeseries_chart.js:30: crosshairDots.style.display = 'none
';
scubaduck/static/js/timeseries_chart.js:111: crosshairLine,
scubaduck/static/js/timeseries_chart.js:112: crosshairDots,
scubaduck/static/js/timeseries_chart.js:331: svg.appendChild(crosshairLine);
scubaduck/static/js/timeseries_chart.js:332: svg.appendChild(crosshairDots);
scubaduck/static/js/timeseries_chart.js:370: crosshairLine.style.display = 'n
one';
scubaduck/static/js/timeseries_chart.js:371: crosshairDots.style.display = 'n
one';
scubaduck/static/js/timeseries_chart.js:372: crosshairDots.innerHTML = '';
scubaduck/static/js/timeseries_chart.js:400: crosshairLine.setAttribute('x1',
xPix);
scubaduck/static/js/timeseries_chart.js:401: crosshairLine.setAttribute('x2',
xPix);
scubaduck/static/js/timeseries_chart.js:402: crosshairLine.setAttribute('y1',
currentChart.yScale(currentChart.maxY));
scubaduck/static/js/timeseries_chart.js:403: crosshairLine.setAttribute('y2',
currentChart.yScale(currentChart.minY));
scubaduck/static/js/timeseries_chart.js:404: crosshairLine.style.display = 'b
lock';
scubaduck/static/js/timeseries_chart.js:405: crosshairDots.style.display = 'b
lock';
scubaduck/static/js/timeseries_chart.js:406: crosshairDots.innerHTML = '';
scubaduck/static/js/timeseries_chart.js:423: crosshairDots.appendChild(dot)
;
tests/test_web.py:280:def test_timeseries_crosshair(page: Any, server_url: str)
-> None:
tests/test_web.py:293: "document.getElementById('crosshair_line').style.d
isplay"
tests/test_web.py:296: count = page.eval_on_selector_all("#crosshair_dots cir
cle", "els => els.length")
tests/test_web.py:303: "document.getElementById('crosshair_line').style.d
isplay"
.venv/lib/python3.12/site-packages/pyright/dist/dist/typeshed-fallback/stubs/pyt
hon-xlib/Xlib/Xcursorfont.pyi:21:crosshair: Final = 34
bash: .venv/bin/activate: No such file or directory
root@09b91c3ec8d3:/workspace# ls
scubaduck
root@09b91c3ec8d3:/workspace# cd scubaduck
root@09b91c3ec8d3:/workspace/scubaduck# ls
AGENTS.md codex_setup.sh scubaduck tests
README.md pyproject.toml stubs uv.lock
I'm going to open the other JS file now. Let's check it out.
root@09b91c3ec8d3:/workspace/scubaduck# cat scubaduck/static/js/chip_input.js |
head -n 20
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');
filter.chips = [];
filter.renderChips = renderChips;
filter.addChip = addChip;
let highlight = 0;
let dropdownLocked = false;
chipsEl.addEventListener('click', () => {
input.focus();
});
function renderChips() {
chipsEl.querySelectorAll('.chip').forEach(c => c.remove());
filter.chips.forEach((v, i) => {
const span = document.createElement('span');
I'll open index.html to check out the crosshair code.
root@09b91c3ec8d3:/workspace/scubaduck# cat scubaduck/static/index.html | head -
n 80
<!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;
}
#derived_columns .derived {
border: 1px solid #ccc;
padding: 5px;
margin-bottom: 5px;
display: flex;
flex-direction: column;
}
#derived_columns .derived-row {
display: flex;
margin-bottom: 5px;
}
#derived_columns .derived-row input[type="text"] {
margin-left: 5px;
flex: 1;
}
#derived_columns .derived-row button.remove {
margin-left: 5px;
width: 20px;
flex: 0 0 auto;
padding: 0;
text-align: center;
line-height: 1;
}
#derived_columns textarea {
width: 100%;
box-sizing: border-box;
}
#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; }
I'll continue scrolling to review the timeseries section.
root@09b91c3ec8d3:/workspace/scubaduck# grep -n timeseries scubaduck/static/inde
x.html
177: <div id="header">sample.csv - <select id="table"></select> <select id="gra
ph_type"><option value="samples">Samples</option><option value="table">Table</op
tion><option value="timeseries">Time Series</option></select></div>
328:<script src="/js/timeseries_chart.js"></script>
465: const showTS = graphTypeSel.value === 'timeseries';
684: if (graphTypeSel.value === 'table' || graphTypeSel.value === 'timeseries')
{
943: if (graphTypeSel.value === 'table' || graphTypeSel.value === 'timeseries')
{
948: if (graphTypeSel.value === 'timeseries') {
968: if (params.graph_type === 'table' || params.graph_type === 'timeseries') {
973: if (params.graph_type === 'timeseries') {
1190: if (graphTypeSel.value === 'timeseries') {
I'll dig into the timeseries section to check it out.
root@09b91c3ec8d3:/workspace/scubaduck# sed -n '460,510p' scubaduck/static/index
.html
orderDirBtn.textContent = orderDir + (orderDir === 'ASC' ? ' \u25B2' : ' \u25B
C');
}
function updateDisplayTypeUI() {
const showTable = graphTypeSel.value === 'table';
const showTS = graphTypeSel.value === 'timeseries';
document.getElementById('group_by_field').style.display = showTable || showTS
? 'flex' : 'none';
document.getElementById('aggregate_field').style.display = showTable || showTS
? 'flex' : 'none';
document.getElementById('show_hits_field').style.display = showTable ? 'flex'
: 'none';
document.getElementById('x_axis_field').style.display = showTS ? 'flex' : 'non
e';
document.getElementById('granularity_field').style.display = showTS ? 'flex' :
'none';
document.getElementById('fill_field').style.display = showTS ? 'flex' : 'none'
;
document.querySelectorAll('#column_groups .col-group').forEach(g => {
if (g.querySelector('.col-group-header').textContent.startsWith('Strings'))
{
g.style.display = showTable || showTS ? 'none' : '';
}
});
if (showTS) {
const lim = document.getElementById('limit');
if (!lim.dataset.setByUser) {
lim.value = '7';
}
document.querySelectorAll('#column_groups input').forEach(cb => {
if (isTimeColumn(cb.value) || isStringColumn(cb.value)) {
cb.checked = false;
}
});
document.getElementById('order_by').value = '';
updateSelectedColumns();
}
displayType = graphTypeSel.value;
}
orderDirBtn.addEventListener('click', () => {
orderDir = orderDir === 'ASC' ? 'DESC' : 'ASC';
updateOrderDirButton();
});
updateOrderDirButton();
graphTypeSel.addEventListener('change', updateDisplayTypeUI);
function loadColumns(table) {
return fetch('/api/columns?table=' + encodeURIComponent(table)).then(r => r.js
on()).then(cols => {
const orderSelect = document.getElementById('order_by');
const xAxisSelect = document.getElementById('x_axis');
const groupsEl = document.getElementById('column_groups');
orderSelect.innerHTML = '';
xAxisSelect.innerHTML = '';
groupsEl.innerHTML = '';
allColumns.length = 0;
stringColumns.length = 0;
integerColumns.length = 0;
timeColumns.length = 0;
I’m browsing down to locate the crosshair event. Let’s track it!
root@09b91c3ec8d3:/workspace/scubaduck# grep -n crosshair -n scubaduck/static/in
dex.html
I'm checking timeseries_chart.js around line 364 to understand the current crosshair behavior.
root@09b91c3ec8d3:/workspace/scubaduck# sed -n '340,460p' scubaduck/static/js/ti
meseries_chart.js
axisLine.setAttribute('x1', xScale(minX));
axisLine.setAttribute('x2', xScale(maxX));
axisLine.setAttribute('y1', height - 30);
axisLine.setAttribute('y2', height - 30);
axisLine.setAttribute('stroke', '#888');
axis.appendChild(axisLine);
ticks.forEach(t => {
const x = xScale(t);
const line = document.createElementNS('http://www.w3.org/2000/svg', 'line'
);
line.setAttribute('x1', x);
line.setAttribute('y1', height - 30);
line.setAttribute('x2', x);
line.setAttribute('y2', height - 25);
line.setAttribute('stroke', '#888');
axis.appendChild(line);
const text = document.createElementNS('http://www.w3.org/2000/svg', 'text'
);
text.setAttribute('x', x);
text.setAttribute('y', height - 10);
text.setAttribute('text-anchor', 'middle');
text.setAttribute('class', 'tick-label' + (rotate ? ' rotated' : ''));
if (rotate) text.setAttribute('transform', `rotate(-45 ${x} ${height - 10}
)`);
text.textContent = fmt(new Date(t), lu);
axis.appendChild(text);
});
svg.appendChild(axis);
}
render();
function hideCrosshair() {
crosshairLine.style.display = 'none';
crosshairDots.style.display = 'none';
crosshairDots.innerHTML = '';
Object.values(currentChart.seriesEls).forEach(el => {
el.valueEl.textContent = '';
});
if (currentChart.selected) {
currentChart.seriesEls[currentChart.selected].highlight(false);
currentChart.selected = null;
}
}
svg.addEventListener('mouseleave', hideCrosshair);
svg.addEventListener('mousemove', e => {
const rect = svg.getBoundingClientRect();
const x = e.clientX - rect.left;
const y = e.clientY - rect.top;
const pixels = currentChart.bucketPixels;
if (!pixels.length) return;
let idx = 0;
let dist = Math.abs(pixels[0] - x);
for (let i = 1; i < pixels.length; i++) {
const d = Math.abs(pixels[i] - x);
if (d < dist) {
dist = d;
idx = i;
}
}
const bucket = currentChart.buckets[idx];
const xPix = pixels[idx];
crosshairLine.setAttribute('x1', xPix);
crosshairLine.setAttribute('x2', xPix);
crosshairLine.setAttribute('y1', currentChart.yScale(currentChart.maxY));
crosshairLine.setAttribute('y2', currentChart.yScale(currentChart.minY));
crosshairLine.style.display = 'block';
crosshairDots.style.display = 'block';
crosshairDots.innerHTML = '';
const options = [];
Object.keys(currentChart.series).forEach(key => {
const vals = currentChart.series[key];
let v = vals[bucket];
if (v === undefined && currentChart.fill !== '0') {
currentChart.seriesEls[key].valueEl.textContent = '';
return;
}
if (v === undefined) v = 0;
currentChart.seriesEls[key].valueEl.textContent = formatNumber(v);
const yPix = currentChart.yScale(v);
const dot = document.createElementNS('http://www.w3.org/2000/svg', 'circle
');
dot.setAttribute('cx', xPix);
dot.setAttribute('cy', yPix);
dot.setAttribute('r', '3');
dot.setAttribute('fill', currentChart.seriesEls[key].color);
crosshairDots.appendChild(dot);
options.push({ key, y: yPix });
});
if (options.length) {
let best = options[0];
let bestDist = Math.abs(best.y - y);
for (let i = 1; i < options.length; i++) {
const d = Math.abs(options[i].y - y);
if (d < bestDist) {
best = options[i];
bestDist = d;
}
}
if (currentChart.selected && currentChart.selected !== best.key) {
currentChart.seriesEls[currentChart.selected].highlight(false);
}
currentChart.seriesEls[best.key].highlight(true);
currentChart.selected = best.key;
}
});
if (resizeObserver) resizeObserver.disconnect();
resizeObserver = new ResizeObserver(render);
resizeObserver.observe(svg.parentElement);
}
I'll check for click handlers and ensure the crosshair is referenced in other functions.
root@09b91c3ec8d3:/workspace/scubaduck# grep -n freeze -R scubaduck/static/js
I'll add a frozen
state to currentChart
and toggle it on click to freeze/unfreeze the crosshair.
On click, I'll toggle currentChart.frozen
and update the crosshair accordingly, keeping it frozen.
On unfreeze, I'll hide the crosshair and reset its visibility until the next mousemove.
root@09b91c3ec8d3:/workspace/scubaduck# sed -n '270,310p' tests/test_web.py
width = page.evaluate(
"getComputedStyle(document.querySelector('#chart path')).strokeWidth"
)
assert "2.5" in width
color = page.evaluate(
"getComputedStyle(document.querySelector('#legend .legend-item')).backgr
oundColor"
)
assert "221, 221, 221" in color
def test_timeseries_crosshair(page: Any, server_url: str) -> None:
page.goto(server_url)
page.wait_for_selector("#graph_type", state="attached")
select_value(page, "#graph_type", "timeseries")
page.evaluate("window.lastResults = undefined")
page.click("text=Dive")
page.wait_for_function("window.lastResults !== undefined")
page.wait_for_selector("#chart path", state="attached")
page.eval_on_selector(
"#chart",
"el => { const r = el.getBoundingClientRect(); el.dispatchEvent(new Mous
eEvent('mousemove', {clientX: r.left + r.width/2, clientY: r.top + r.height/2, b
ubbles: true})); }",
)
line_display = page.evaluate(
"document.getElementById('crosshair_line').style.display"
)
assert line_display != "none"
count = page.eval_on_selector_all("#crosshair_dots circle", "els => els.leng
th")
assert count > 0
page.eval_on_selector(
"#chart",
"el => el.dispatchEvent(new MouseEvent('mouseleave', {bubbles: true}))",
)
line_display = page.evaluate(
"document.getElementById('crosshair_line').style.display"
)
assert line_display == "none"
def test_timeseries_auto_timezone(browser: Any, server_url: str) -> None:
context = browser.new_context(timezone_id="America/New_York")
page = context.new_page()
I'll add a new test for freezing and unfreezing the crosshair. I'll search for related tests.
root@09b91c3ec8d3:/workspace/scubaduck# grep -n crosshair -n tests/test_web.py
280:def test_timeseries_crosshair(page: Any, server_url: str) -> None:
293: "document.getElementById('crosshair_line').style.display"
296: count = page.eval_on_selector_all("#crosshair_dots circle", "els => els.
length")
303: "document.getElementById('crosshair_line').style.display"
I'll adjust timeseries_chart.js
and add a new test. Then I'll check test_web
for more functions.
root@09b91c3ec8d3:/workspace/scubaduck# sed -n '308,340p' tests/test_web.py
def test_timeseries_auto_timezone(browser: Any, server_url: str) -> None:
context = browser.new_context(timezone_id="America/New_York")
page = context.new_page()
page.goto(server_url)
page.wait_for_selector("#graph_type", state="attached")
select_value(page, "#graph_type", "timeseries")
page.evaluate("window.lastResults = undefined")
page.click("text=Dive")
page.wait_for_function("window.lastResults !== undefined")
path = page.get_attribute("#chart path", "d")
context.close()
assert path is not None
coords = [float(p.split(" ")[1]) for p in path.replace("M", "L").split("L")[
1:]]
assert max(coords) > min(coords)
def test_timeseries_multi_series(page: Any, server_url: str) -> None:
page.goto(server_url)
page.wait_for_selector("#graph_type", state="attached")
select_value(page, "#graph_type", "timeseries")
page.click("text=Columns")
page.click("text=Add Derived")
expr = page.query_selector("#derived_list .derived textarea")
assert expr
name_inp = page.query_selector("#derived_list .derived .d-name")
assert name_inp
name_inp.fill("value_2")
expr.fill("value * 2")
page.click("text=View Settings")
page.fill("#start", "2024-01-01 00:00:00")
page.fill("#end", "2024-01-03 00:00:00")
select_value(page, "#granularity", "1 hour")
page.evaluate("window.lastResults = undefined")
I see that the crosshair test is around line 280. I'll look at the pyproject to identify the test runner.
root@09b91c3ec8d3:/workspace/scubaduck# cat pyproject.toml
[project]
name = "scubaduck"
version = "0.1.0"
description = "Scuba on DuckDB"
readme = "README.md"
requires-python = ">=3.12"
license = {text = "MIT"}
dependencies = [
"duckdb",
"flask",
"python-dateutil>=2.9.0.post0",
]
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"
[tool.pytest.ini_options]
addopts = "-n auto --tb=native"
[tool.pyright]
# Pyright configuration with strict settings
include = ["scubaduck", "tests"]
exclude = ["**/__pycache__", "dist"]
stubPath = "stubs"
venvPath = "."
venv = ".venv"
reportMissingImports = true
reportMissingTypeStubs = true
pythonVersion = "3.12"
pythonPlatform = "All"
typeCheckingMode = "strict"
reportUnknownMemberType = true
reportUnknownParameterType = true
reportUnknownVariableType = true
reportUnknownArgumentType = true
reportPrivateImportUsage = true
reportUntypedFunctionDecorator = true
reportFunctionMemberAccess = true
reportIncompatibleMethodOverride = true
[tool.ruff]
target-version = "py312"
[tool.uv]
dev-dependencies = [
"pytest>=8.3.5",
"ruff>=0.11.2",
"pytest-xdist>=3.6.1",
"playwright>=1.52.0",
"pyright>=1.1.350",
"pytest-playwright>=0.7.0",
]
I'll check the server code to see why the crosshair isn't included.
root@09b91c3ec8d3:/workspace/scubaduck# ls scubaduck
__init__.py sample.csv server.py static
I’ll take a look at server.py to see what’s going on.
root@09b91c3ec8d3:/workspace/scubaduck# grep -n crosshair -R scubaduck
scubaduck/static/js/timeseries_chart.js:23: const crosshairLine = document.crea
teElementNS('http://www.w3.org/2000/svg', 'line');
scubaduck/static/js/timeseries_chart.js:24: crosshairLine.id = 'crosshair_line'
;
scubaduck/static/js/timeseries_chart.js:25: crosshairLine.setAttribute('stroke'
, '#555');
scubaduck/static/js/timeseries_chart.js:26: crosshairLine.style.display = 'none
';
scubaduck/static/js/timeseries_chart.js:28: const crosshairDots = document.crea
teElementNS('http://www.w3.org/2000/svg', 'g');
scubaduck/static/js/timeseries_chart.js:29: crosshairDots.id = 'crosshair_dots'
;
scubaduck/static/js/timeseries_chart.js:30: crosshairDots.style.display = 'none
';
scubaduck/static/js/timeseries_chart.js:111: crosshairLine,
scubaduck/static/js/timeseries_chart.js:112: crosshairDots,
scubaduck/static/js/timeseries_chart.js:331: svg.appendChild(crosshairLine);
scubaduck/static/js/timeseries_chart.js:332: svg.appendChild(crosshairDots);
scubaduck/static/js/timeseries_chart.js:370: crosshairLine.style.display = 'n
one';
scubaduck/static/js/timeseries_chart.js:371: crosshairDots.style.display = 'n
one';
scubaduck/static/js/timeseries_chart.js:372: crosshairDots.innerHTML = '';
scubaduck/static/js/timeseries_chart.js:400: crosshairLine.setAttribute('x1',
xPix);
scubaduck/static/js/timeseries_chart.js:401: crosshairLine.setAttribute('x2',
xPix);
scubaduck/static/js/timeseries_chart.js:402: crosshairLine.setAttribute('y1',
currentChart.yScale(currentChart.maxY));
scubaduck/static/js/timeseries_chart.js:403: crosshairLine.setAttribute('y2',
currentChart.yScale(currentChart.minY));
scubaduck/static/js/timeseries_chart.js:404: crosshairLine.style.display = 'b
lock';
scubaduck/static/js/timeseries_chart.js:405: crosshairDots.style.display = 'b
lock';
scubaduck/static/js/timeseries_chart.js:406: crosshairDots.innerHTML = '';
scubaduck/static/js/timeseries_chart.js:423: crosshairDots.appendChild(dot)
;
I'm going to take a look at the init.py file to see what's inside.
root@09b91c3ec8d3:/workspace/scubaduck# cat scubaduck/__init__.py
def hello() -> str:
return "Hello from scubaduck!"
I'll implement the crosshair freeze test by simulating mouse movements and clicks.
The click should hide the crosshair. I'll update the test and check visibility post-click.
root@09b91c3ec8d3:/workspace/scubaduck# cd /workspace/scubaduck
I'm taking a look at the current status of the Git repository.
root@09b91c3ec8d3:/workspace/scubaduck# git status --short
I'll activate the virtual environment first, as AGENTS recommend, with source .venv/bin/activate
.
root@09b91c3ec8d3:/workspace/scubaduck# source .venv/bin/activate
(scubaduck) root@09b91c3ec8d3:/workspace/scubaduck#
I'll open timeseries_chart.js to make the necessary edits.
(scubaduck) root@09b91c3ec8d3:/workspace/scubaduck# sed -n '100,460p' scubaduck/
static/js/timeseries_chart.js
svg,
legend,
series,
buckets,
minX,
maxX,
minY,
maxY,
fill,
colors,
height,
crosshairLine,
crosshairDots,
seriesEls: {},
bucketPixels: [],
xScale: null,
yScale: null,
selected: null
};
const intervals = [
{unit: 'second', step: 1, ms: 1000},
{unit: 'second', step: 2, ms: 2000},
{unit: 'second', step: 5, ms: 5000},
{unit: 'second', step: 10, ms: 10000},
{unit: 'second', step: 15, ms: 15000},
{unit: 'second', step: 30, ms: 30000},
{unit: 'minute', step: 1, ms: 60000},
{unit: 'minute', step: 2, ms: 120000},
{unit: 'minute', step: 5, ms: 300000},
{unit: 'minute', step: 10, ms: 600000},
{unit: 'minute', step: 15, ms: 900000},
{unit: 'minute', step: 30, ms: 1800000},
{unit: 'hour', step: 1, ms: 3600000},
{unit: 'hour', step: 2, ms: 7200000},
{unit: 'hour', step: 3, ms: 10800000},
{unit: 'hour', step: 4, ms: 14400000},
{unit: 'hour', step: 6, ms: 21600000},
{unit: 'hour', step: 12, ms: 43200000},
{unit: 'day', step: 1, ms: 86400000},
{unit: 'day', step: 2, ms: 172800000},
{unit: 'week', step: 1, ms: 604800000},
{unit: 'week', step: 2, ms: 1209600000},
{unit: 'month', step: 1},
{unit: 'month', step: 3},
{unit: 'month', step: 6},
{unit: 'year', step: 1},
{unit: 'year', step: 2},
{unit: 'year', step: 5},
{unit: 'year', step: 10}
];
function chooseInterval(start, end) {
const span = end - start;
function approxMs(i) {
if (i.ms) return i.ms;
if (i.unit === 'month') return i.step * 2629800000;
if (i.unit === 'year') return i.step * 31557600000;
return 1000;
}
let best = intervals[0];
let bestScore = Infinity;
intervals.forEach(i => {
const count = span / approxMs(i);
const score = Math.abs(count - 15);
if (score < bestScore) {
best = i;
bestScore = score;
}
});
return best;
}
function generateTicks(start, end, intv) {
const ticks = [];
if (intv.unit === 'month' || intv.unit === 'year') {
let d = new Date(start);
d.setUTCDate(1);
if (intv.unit === 'year') d.setUTCMonth(0);
let unitVal =
intv.unit === 'month'
? d.getUTCFullYear() * 12 + d.getUTCMonth()
: d.getUTCFullYear();
unitVal = Math.ceil(unitVal / intv.step) * intv.step;
while (true) {
const year =
intv.unit === 'month' ? Math.floor(unitVal / 12) : unitVal;
const month = intv.unit === 'month' ? unitVal % 12 : 0;
const t = Date.UTC(year, month, 1);
if (t > end) break;
if (t >= start) ticks.push(t);
unitVal += intv.step;
}
} else {
const step = intv.ms * intv.step;
let t = Math.ceil(start / step) * step;
if (intv.unit === 'week') {
const d = new Date(t);
const adj = (d.getUTCDay() + 6) % 7;
t = d.getTime() - adj * 86400000;
t = Math.ceil(t / step) * step;
}
if (t === start) t += step;
for (; t <= end; t += step) ticks.push(t);
}
return ticks;
}
function labelUnit(intv) {
if (intv.unit === 'year') return 'year';
if (intv.unit === 'month') return 'month';
if (intv.unit === 'day' || intv.unit === 'week') return 'day';
if (intv.unit === 'hour') return 'hour';
return 'minute';
}
function fmt(date, unit) {
const pad = n => String(n).padStart(2, '0');
const mon = date.toLocaleString('en-US', {month: 'short'});
switch (unit) {
case 'year':
return String(date.getFullYear());
...
currentChart.yScale = yScale;
currentChart.bucketPixels = buckets.map(xScale);
svg.appendChild(crosshairLine);
svg.appendChild(crosshairDots);
const intv = chooseInterval(minX, maxX);
const ticks = generateTicks(minX, maxX, intv);
const lu = labelUnit(intv);
const rotate = ticks.length > 0 && (width - 60) / ticks.length < 60;
const axis = document.createElementNS('http://www.w3.org/2000/svg', 'g');
const axisLine = document.createElementNS('http://www.w3.org/2000/svg', 'lin
e');
axisLine.setAttribute('x1', xScale(minX));
axisLine.setAttribute('x2', xScale(maxX));
axisLine.setAttribute('y1', height - 30);
axisLine.setAttribute('y2', height - 30);
axisLine.setAttribute('stroke', '#888');
axis.appendChild(axisLine);
ticks.forEach(t => {
const x = xScale(t);
const line = document.createElementNS('http://www.w3.org/2000/svg', 'line'
);
line.setAttribute('x1', x);
line.setAttribute('y1', height - 30);
line.setAttribute('x2', x);
line.setAttribute('y2', height - 25);
line.setAttribute('stroke', '#888');
axis.appendChild(line);
const text = document.createElementNS('http://www.w3.org/2000/svg', 'text'
);
text.setAttribute('x', x);
text.setAttribute('y', height - 10);
text.setAttribute('text-anchor', 'middle');
text.setAttribute('class', 'tick-label' + (rotate ? ' rotated' : ''));
if (rotate) text.setAttribute('transform', `rotate(-45 ${x} ${height - 10}
)`);
text.textContent = fmt(new Date(t), lu);
axis.appendChild(text);
});
svg.appendChild(axis);
}
render();
function hideCrosshair() {
crosshairLine.style.display = 'none';
crosshairDots.style.display = 'none';
crosshairDots.innerHTML = '';
Object.values(currentChart.seriesEls).forEach(el => {
el.valueEl.textContent = '';
});
if (currentChart.selected) {
currentChart.seriesEls[currentChart.selected].highlight(false);
currentChart.selected = null;
}
}
svg.addEventListener('mouseleave', hideCrosshair);
svg.addEventListener('mousemove', e => {
const rect = svg.getBoundingClientRect();
const x = e.clientX - rect.left;
const y = e.clientY - rect.top;
const pixels = currentChart.bucketPixels;
if (!pixels.length) return;
let idx = 0;
let dist = Math.abs(pixels[0] - x);
for (let i = 1; i < pixels.length; i++) {
const d = Math.abs(pixels[i] - x);
if (d < dist) {
dist = d;
idx = i;
}
}
const bucket = currentChart.buckets[idx];
const xPix = pixels[idx];
crosshairLine.setAttribute('x1', xPix);
crosshairLine.setAttribute('x2', xPix);
crosshairLine.setAttribute('y1', currentChart.yScale(currentChart.maxY));
crosshairLine.setAttribute('y2', currentChart.yScale(currentChart.minY));
crosshairLine.style.display = 'block';
crosshairDots.style.display = 'block';
crosshairDots.innerHTML = '';
const options = [];
Object.keys(currentChart.series).forEach(key => {
const vals = currentChart.series[key];
let v = vals[bucket];
if (v === undefined && currentChart.fill !== '0') {
currentChart.seriesEls[key].valueEl.textContent = '';
return;
}
if (v === undefined) v = 0;
currentChart.seriesEls[key].valueEl.textContent = formatNumber(v);
const yPix = currentChart.yScale(v);
const dot = document.createElementNS('http://www.w3.org/2000/svg', 'circle
');
dot.setAttribute('cx', xPix);
dot.setAttribute('cy', yPix);
dot.setAttribute('r', '3');
dot.setAttribute('fill', currentChart.seriesEls[key].color);
crosshairDots.appendChild(dot);
options.push({ key, y: yPix });
});
if (options.length) {
let best = options[0];
let bestDist = Math.abs(best.y - y);
for (let i = 1; i < options.length; i++) {
const d = Math.abs(options[i].y - y);
if (d < bestDist) {
best = options[i];
bestDist = d;
}
}
if (currentChart.selected && currentChart.selected !== best.key) {
currentChart.seriesEls[currentChart.selected].highlight(false);
}
currentChart.seriesEls[best.key].highlight(true);
currentChart.selected = best.key;
}
});
if (resizeObserver) resizeObserver.disconnect();
resizeObserver = new ResizeObserver(render);
resizeObserver.observe(svg.parentElement);
}
(scubaduck) root@09b91c3ec8d3:/workspace/scubaduck#
I reached the end of the file, but let's double-check for anything I missed.
(scubaduck) root@09b91c3ec8d3:/workspace/scubaduck# sed -n '460,520p' scubaduck/
static/js/timeseries_chart.js
(scubaduck) root@09b91c3ec8d3:/workspace/scubaduck#
I'm adding a frozen
property to currentChart
. I'll refactor the crosshair logic into updateCrosshair
, and ensure mousemove and click events work smoothly without duplication.
I'll ensure the crosshair highlights the closest series when frozen and clears on unfreeze.
(scubaduck) root@09b91c3ec8d3:/workspace/scubaduck# apply_patch<<'PATCH'
> *** Begin Patch
> *** Update File: scubaduck/static/js/timeseries_chart.js
> @@
> crosshairDots,
> seriesEls: {},
> bucketPixels: [],
> xScale: null,
> yScale: null,
> - selected: null
> + selected: null,
> + frozen: false
> };
> *** End Patch
> PATCH
Success. Updated the following files:
M scubaduck/static/js/timeseries_chart.js
(scubaduck) root@09b91c3ec8d3:/workspace/scubaduck#
I'll patch the new functions below 'render();' or before event listeners, focusing on crosshair.
(scubaduck) root@09b91c3ec8d3:/workspace/scubaduck# grep -n "render();" -n scuba
duck/static/js/timeseries_chart.js
368: render();
(scubaduck) root@09b91c3ec8d3:/workspace/scubaduck#
I'll open the area around here to apply the necessary patch.
(scubaduck) root@09b91c3ec8d3:/workspace/scubaduck# sed -n '360,430p' scubaduck/
static/js/timeseries_chart.js
text.setAttribute('class', 'tick-label' + (rotate ? ' rotated' : ''));
if (rotate) text.setAttribute('transform', `rotate(-45 ${x} ${height - 10}
)`);
text.textContent = fmt(new Date(t), lu);
axis.appendChild(text);
});
svg.appendChild(axis);
}
render();
function hideCrosshair() {
crosshairLine.style.display = 'none';
crosshairDots.style.display = 'none';
crosshairDots.innerHTML = '';
Object.values(currentChart.seriesEls).forEach(el => {
el.valueEl.textContent = '';
});
if (currentChart.selected) {
currentChart.seriesEls[currentChart.selected].highlight(false);
currentChart.selected = null;
}
}
svg.addEventListener('mouseleave', hideCrosshair);
svg.addEventListener('mousemove', e => {
const rect = svg.getBoundingClientRect();
const x = e.clientX - rect.left;
const y = e.clientY - rect.top;
const pixels = currentChart.bucketPixels;
if (!pixels.length) return;
let idx = 0;
let dist = Math.abs(pixels[0] - x);
for (let i = 1; i < pixels.length; i++) {
const d = Math.abs(pixels[i] - x);
if (d < dist) {
dist = d;
idx = i;
}
}
const bucket = currentChart.buckets[idx];
const xPix = pixels[idx];
crosshairLine.setAttribute('x1', xPix);
crosshairLine.setAttribute('x2', xPix);
crosshairLine.setAttribute('y1', currentChart.yScale(currentChart.maxY));
crosshairLine.setAttribute('y2', currentChart.yScale(currentChart.minY));
crosshairLine.style.display = 'block';
crosshairDots.style.display = 'block';
crosshairDots.innerHTML = '';
const options = [];
Object.keys(currentChart.series).forEach(key => {
const vals = currentChart.series[key];
let v = vals[bucket];
if (v === undefined && currentChart.fill !== '0') {
currentChart.seriesEls[key].valueEl.textContent = '';
return;
}
if (v === undefined) v = 0;
currentChart.seriesEls[key].valueEl.textContent = formatNumber(v);
const yPix = currentChart.yScale(v);
const dot = document.createElementNS('http://www.w3.org/2000/svg', 'circle
');
dot.setAttribute('cx', xPix);
dot.setAttribute('cy', yPix);
dot.setAttribute('r', '3');
dot.setAttribute('fill', currentChart.seriesEls[key].color);
crosshairDots.appendChild(dot);
options.push({ key, y: yPix });
});
if (options.length) {
let best = options[0];
let bestDist = Math.abs(best.y - y);
for (let i = 1; i < options.length; i++) {
(scubaduck) root@09b91c3ec8d3:/workspace/scubaduck# sed -n '430,520p' scubaduck/
static/js/timeseries_chart.js
for (let i = 1; i < options.length; i++) {
const d = Math.abs(options[i].y - y);
if (d < bestDist) {
best = options[i];
bestDist = d;
}
}
if (currentChart.selected && currentChart.selected !== best.key) {
currentChart.seriesEls[currentChart.selected].highlight(false);
}
currentChart.seriesEls[best.key].highlight(true);
currentChart.selected = best.key;
}
});
if (resizeObserver) resizeObserver.disconnect();
resizeObserver = new ResizeObserver(render);
resizeObserver.observe(svg.parentElement);
}
(scubaduck) root@09b91c3ec8d3:/workspace/scubaduck#
Time to define updateCrosshair
—I'll patch hideCrosshair, mousemove, and add a click listener.
(scubaduck) root@09b91c3ec8d3:/workspace/scubaduck# apply_patch<<'PATCH'
> *** Begin Patch
isplay = 'block'> *** Update File: scubaduck/static/js/timeseries_chart.js
ck';
+ crossh> @@
> - function hideCrosshair() {
> - crosshairLine.style.display = 'none';
> - crosshairDots.style.display = 'none';
onst va> - crosshairDots.innerHTML = '';
> - Object.values(currentChart.seriesEls).forEach(el => {
> - el.valueEl.textContent = '';
> - });
> - if (currentChart.selected) {
> - currentChart.seriesEls[currentChart.selected].highlight(false);
+> - currentChart.selected = null;
> - }
> - }
> -
> - svg.addEventListener('mouseleave', hideCrosshair);
> - svg.addEventListener('mousemove', e => {
> - const rect = svg.getBoundingClientRect();
> - const x = e.clientX - rect.left;
> - const y = e.clientY - rect.top;
> - const pixels = currentChart.bucketPixels;
> - if (!pixels.length) return;
> - let idx = 0;
> - let dist = Math.abs(pixels[0] - x);
> - for (let i = 1; i < pixels.length; i++) {
> - const d = Math.abs(pixels[i] - x);
> - if (d < dist) {
let best = options[0];> - dist = d;
tDis> - idx = i;
t = Math.abs(best.> - }
y - y);
+> - }
> - const bucket = currentChart.buckets[idx];
> - const xPix = pixels[idx];
options[> - crosshairLine.setAttribute('x1', xPix);
> - crosshairLine.setAttribute('x2', xPix);
> - crosshairLine.setAttribute('y1', currentChart.yScale(currentChart.maxY));
> - crosshairLine.setAttribute('y2', currentChart.yScale(currentChart.minY));
> - crosshairLine.style.display = 'block';
> - crosshairDots.style.display = 'block';
> - crosshairDots.innerHTML = '';
> - const options = [];
> - Object.keys(currentChart.series).forEach(key => {
addEven> - const vals = currentChart.series[key];
> - let v = vals[bucket];
> - if (v === undefined && currentChart.fill !== '0') {
> - currentChart.seriesEls[key].valueEl.textContent = '';
currentChart.fro> - return;
> - }
> - if (v === undefined) v = 0;
> - currentChart.seriesEls[key].valueEl.textContent = formatNumber(v);
}
+ });
*** End > - const yPix = currentChart.yScale(v);
> - const dot = document.createElementNS('http://www.w3.org/2000/svg', 'cir
cle');
> - dot.setAttribute('cx', xPix);
> - dot.setAttribute('cy', yPix);
> - dot.setAttribute('r', '3');
> - dot.setAttribute('fill', currentChart.seriesEls[key].color);
> - crosshairDots.appendChild(dot);
> - options.push({ key, y: yPix });
> - });
> - if (options.length) {
> - let best = options[0];
> - let bestDist = Math.abs(best.y - y);
> - for (let i = 1; i < options.length; i++) {
> - const d = Math.abs(options[i].y - y);
> - if (d < bestDist) {
> - best = options[i];
> - bestDist = d;
> - }
> - }
> - if (currentChart.selected && currentChart.selected !== best.key) {
> - currentChart.seriesEls[currentChart.selected].highlight(false);
> - }
> - currentChart.seriesEls[best.key].highlight(true);
> - currentChart.selected = best.key;
> - }
> - });
> + function hideCrosshair() {
> + if (currentChart.frozen) return;
> + crosshairLine.style.display = 'none';
> + crosshairDots.style.display = 'none';
> + crosshairDots.innerHTML = '';
> + Object.values(currentChart.seriesEls).forEach(el => {
> + el.valueEl.textContent = '';
> + });
> + if (currentChart.selected) {
> + currentChart.seriesEls[currentChart.selected].highlight(false);
> + currentChart.selected = null;
> + }
> + }
> +
> + function updateCrosshair(e) {
> + const rect = svg.getBoundingClientRect();
> + const x = e.clientX - rect.left;
> + const y = e.clientY - rect.top;
> + const pixels = currentChart.bucketPixels;
> + if (!pixels.length) return;
> + let idx = 0;
> + let dist = Math.abs(pixels[0] - x);
> + for (let i = 1; i < pixels.length; i++) {
> + const d = Math.abs(pixels[i] - x);
> + if (d < dist) {
> + dist = d;
> + idx = i;
> + }
> + }
> + const bucket = currentChart.buckets[idx];
> + const xPix = pixels[idx];
> + crosshairLine.setAttribute('x1', xPix);
> + crosshairLine.setAttribute('x2', xPix);
> + crosshairLine.setAttribute('y1', currentChart.yScale(currentChart.maxY));
> + crosshairLine.setAttribute('y2', currentChart.yScale(currentChart.minY));
> + crosshairLine.style.display = 'block';
> + crosshairDots.style.display = 'block';
> + crosshairDots.innerHTML = '';
> + const options = [];
> + Object.keys(currentChart.series).forEach(key => {
> + const vals = currentChart.series[key];
> + let v = vals[bucket];
> + if (v === undefined && currentChart.fill !== '0') {
> + currentChart.seriesEls[key].valueEl.textContent = '';
> + return;
> + }
> + if (v === undefined) v = 0;
> + currentChart.seriesEls[key].valueEl.textContent = formatNumber(v);
> + const yPix = currentChart.yScale(v);
> + const dot = document.createElementNS('http://www.w3.org/2000/svg', 'cir
cle');
> + dot.setAttribute('cx', xPix);
> + dot.setAttribute('cy', yPix);
> + dot.setAttribute('r', '3');
> + dot.setAttribute('fill', currentChart.seriesEls[key].color);
> + crosshairDots.appendChild(dot);
> + options.push({ key, y: yPix });
> + });
> + if (options.length) {
> + let best = options[0];
> + let bestDist = Math.abs(best.y - y);
> + for (let i = 1; i < options.length; i++) {
> + const d = Math.abs(options[i].y - y);
> + if (d < bestDist) {
> + best = options[i];
> + bestDist = d;
> + }
> + }
> + if (currentChart.selected && currentChart.selected !== best.key) {
> + currentChart.seriesEls[currentChart.selected].highlight(false);
> + }
> + currentChart.seriesEls[best.key].highlight(true);
> + currentChart.selected = best.key;
> + }
> + }
> +
> + svg.addEventListener('mouseleave', hideCrosshair);
> + svg.addEventListener('mousemove', e => {
> + if (currentChart.frozen) return;
> + updateCrosshair(e);
> + });
> +
> + svg.addEventListener('click', e => {
> + if (currentChart.frozen) {
> + currentChart.frozen = false;
> + hideCrosshair();
> + } else {
> + updateCrosshair(e);
> + currentChart.frozen = true;
> + }
> + });
> *** End Patch
> PATCH
Success. Updated the following files:
M scubaduck/static/js/timeseries_chart.js
(scubaduck) root@09b91c3ec8d3:/workspace/scubaduck#
The patch looks a bit messy, so I’ll review the key lines closely.
(scubaduck) root@09b91c3ec8d3:/workspace/scubaduck# sed -n '360,520p' scubaduck/
static/js/timeseries_chart.js
text.setAttribute('class', 'tick-label' + (rotate ? ' rotated' : ''));
if (rotate) text.setAttribute('transform', `rotate(-45 ${x} ${height - 10}
)`);
text.textContent = fmt(new Date(t), lu);
axis.appendChild(text);
});
svg.appendChild(axis);
}
render();
function hideCrosshair() {
if (currentChart.frozen) return;
crosshairLine.style.display = 'none';
crosshairDots.style.display = 'none';
crosshairDots.innerHTML = '';
Object.values(currentChart.seriesEls).forEach(el => {
el.valueEl.textContent = '';
});
if (currentChart.selected) {
currentChart.seriesEls[currentChart.selected].highlight(false);
currentChart.selected = null;
}
}
function updateCrosshair(e) {
const rect = svg.getBoundingClientRect();
const x = e.clientX - rect.left;
const y = e.clientY - rect.top;
const pixels = currentChart.bucketPixels;
if (!pixels.length) return;
let idx = 0;
let dist = Math.abs(pixels[0] - x);
for (let i = 1; i < pixels.length; i++) {
const d = Math.abs(pixels[i] - x);
if (d < dist) {
dist = d;
idx = i;
}
}
const bucket = currentChart.buckets[idx];
const xPix = pixels[idx];
crosshairLine.setAttribute('x1', xPix);
crosshairLine.setAttribute('x2', xPix);
crosshairLine.setAttribute('y1', currentChart.yScale(currentChart.maxY));
crosshairLine.setAttribute('y2', currentChart.yScale(currentChart.minY));
crosshairLine.style.display = 'block';
crosshairDots.style.display = 'block';
crosshairDots.innerHTML = '';
const options = [];
Object.keys(currentChart.series).forEach(key => {
const vals = currentChart.series[key];
let v = vals[bucket];
if (v === undefined && currentChart.fill !== '0') {
currentChart.seriesEls[key].valueEl.textContent = '';
return;
}
if (v === undefined) v = 0;
currentChart.seriesEls[key].valueEl.textContent = formatNumber(v);
const yPix = currentChart.yScale(v);
const dot = document.createElementNS('http://www.w3.org/2000/svg', 'circle
');
dot.setAttribute('cx', xPix);
dot.setAttribute('cy', yPix);
dot.setAttribute('r', '3');
dot.setAttribute('fill', currentChart.seriesEls[key].color);
crosshairDots.appendChild(dot);
options.push({ key, y: yPix });
});
if (options.length) {
let best = options[0];
let bestDist = Math.abs(best.y - y);
for (let i = 1; i < options.length; i++) {
const d = Math.abs(options[i].y - y);
if (d < bestDist) {
best = options[i];
bestDist = d;
}
}
if (currentChart.selected && currentChart.selected !== best.key) {
currentChart.seriesEls[currentChart.selected].highlight(false);
}
currentChart.seriesEls[best.key].highlight(true);
currentChart.selected = best.key;
}
}
svg.addEventListener('mouseleave', hideCrosshair);
svg.addEventListener('mousemove', e => {
if (currentChart.frozen) return;
updateCrosshair(e);
});
svg.addEventListener('click', e => {
if (currentChart.frozen) {
currentChart.frozen = false;
hideCrosshair();
} else {
updateCrosshair(e);
currentChart.frozen = true;
}
});
if (resizeObserver) resizeObserver.disconnect();
resizeObserver = new ResizeObserver(render);
resizeObserver.observe(svg.parentElement);
}
(scubaduck) root@09b91c3ec8d3:/workspace/scubaduck#
I'll check that the property is properly added with a comma at the crosshair.
(scubaduck) root@09b91c3ec8d3:/workspace/scubaduck# grep -n "frozen" -n scubaduc
k/static/js/timeseries_chart.js
118: frozen: false
371: if (currentChart.frozen) return;
447: if (currentChart.frozen) return;
452: if (currentChart.frozen) {
453: currentChart.frozen = false;
457: currentChart.frozen = true;
(scubaduck) root@09b91c3ec8d3:/workspace/scubaduck#
Got the line numbers, now I'll open the object to inspect it.
(scubaduck) root@09b91c3ec8d3:/workspace/scubaduck# sed -n '108,125p' scubaduck/
static/js/timeseries_chart.js
fill,
colors,
height,
crosshairLine,
crosshairDots,
seriesEls: {},
bucketPixels: [],
xScale: null,
yScale: null,
selected: null,
frozen: false
};
const intervals = [
{unit: 'second', step: 1, ms: 1000},
{unit: 'second', step: 2, ms: 2000},
{unit: 'second', step: 5, ms: 5000},
{unit: 'second', step: 10, ms: 10000},
(scubaduck) root@09b91c3ec8d3:/workspace/scubaduck#
I'll check the previous lines to confirm there's a trailing comma after the property.
(scubaduck) root@09b91c3ec8d3:/workspace/scubaduck# sed -n '117,125p' scubaduck/
static/js/timeseries_chart.js
selected: null,
frozen: false
};
const intervals = [
{unit: 'second', step: 1, ms: 1000},
{unit: 'second', step: 2, ms: 2000},
{unit: 'second', step: 5, ms: 5000},
{unit: 'second', step: 10, ms: 10000},
(scubaduck) root@09b91c3ec8d3:/workspace/scubaduck#
I'll write a new test for crosshair freeze/unfreeze and replicate from the existing test.
_web.py
path_el,
)
width = page.evaluate(
"getComputedStyle(document.querySelector('#chart path')).strokeWidth"
)
assert "2.5" in width
color = page.evaluate(
"getComputedStyle(document.querySelector('#legend .legend-item')).backgr
oundColor"
)
assert "221, 221, 221" in color
def test_timeseries_crosshair(page: Any, server_url: str) -> None:
page.goto(server_url)
page.wait_for_selector("#graph_type", state="attached")
select_value(page, "#graph_type", "timeseries")
page.evaluate("window.lastResults = undefined")
page.click("text=Dive")
page.wait_for_function("window.lastResults !== undefined")
page.wait_for_selector("#chart path", state="attached")
page.eval_on_selector(
"#chart",
"el => { const r = el.getBoundingClientRect(); el.dispatchEvent(new Mous
eEvent('mousemove', {clientX: r.left + r.width/2, clientY: r.top + r.height/2, b
ubbles: true})); }",
)
line_display = page.evaluate(
"document.getElementById('crosshair_line').style.display"
)
assert line_display != "none"
count = page.eval_on_selector_all("#crosshair_dots circle", "els => els.leng
th")
assert count > 0
page.eval_on_selector(
"#chart",
"el => el.dispatchEvent(new MouseEvent('mouseleave', {bubbles: true}))",
)
line_display = page.evaluate(
"document.getElementById('crosshair_line').style.display"
)
assert line_display == "none"
def test_timeseries_auto_timezone(browser: Any, server_url: str) -> None:
context = browser.new_context(timezone_id="America/New_York")
page = context.new_page()
(scubaduck) root@09b91c3ec8d3:/workspace/scubaduck#
I'll add the new test right after the crosshair test, then create a patch.
(scubaduck) root@09b91c3ec8d3:/workspace/scubaduck# grep -n "test_timeseries_cro
sshair" -n tests/test_web.py
280:def test_timeseries_crosshair(page: Any, server_url: str) -> None:
(scubaduck) root@09b91c3ec8d3:/workspace/scubaduck#
I'll add the next test around line 300, right after the current test at line 280.
_web.py
"el => el.dispatchEvent(new MouseEvent('mouseleave', {bubbles: true}))",
)
line_display = page.evaluate(
"document.getElementById('crosshair_line').style.display"
)
assert line_display == "none"
def test_timeseries_auto_timezone(browser: Any, server_url: str) -> None:
context = browser.new_context(timezone_id="America/New_York")
page = context.new_page()
page.goto(server_url)
page.wait_for_selector("#graph_type", state="attached")
select_value(page, "#graph_type", "timeseries")
page.evaluate("window.lastResults = undefined")
page.click("text=Dive")
(scubaduck) root@09b91c3ec8d3:/workspace/scubaduck#
I’ll add a test for crosshair behavior in the timeseries chart. Let’s implement it now!
> *** Update File: tests/test_web.py
> @@
> def test_timeseries_crosshair(page: Any, server_url: str) -> None:
> @@
> assert line_display == "none"
> +
> +
> +def test_timeseries_crosshair_freeze(page: Any, server_url: str) -> None:
> + page.goto(server_url)
> + page.wait_for_selector("#graph_type", state="attached")
> + select_value(page, "#graph_type", "timeseries")
> + page.evaluate("window.lastResults = undefined")
> + page.click("text=Dive")
> + page.wait_for_function("window.lastResults !== undefined")
> + page.wait_for_selector("#chart path", state="attached")
> + page.eval_on_selector(
> + "#chart",
> + "el => { const r = el.getBoundingClientRect(); el.dispatchEvent(new M
ouseEvent('mousemove', {clientX: r.left + r.width/2, clientY: r.top + r.height/2
, bubbles: true})); }",
> + )
> + page.eval_on_selector(
> + "#chart",
> + "el => { const r = el.getBoundingClientRect(); el.dispatchEvent(new M
ouseEvent('click', {clientX: r.left + r.width/2, clientY: r.top + r.height/2, bu
bbles: true})); }",
> + )
> + line_display = page.evaluate(
> + "document.getElementById('crosshair_line').style.display"
> + )
> + assert line_display != "none"
> + pos1 = page.evaluate(
> + "document.getElementById('crosshair_line').getAttribute('x1')"
> + )
> + page.eval_on_selector(
> + "#chart",
> + "el => { const r = el.getBoundingClientRect(); el.dispatchEvent(new M
ouseEvent('mousemove', {clientX: r.left + r.width/4, clientY: r.top + r.height/2
, bubbles: true})); }",
> + )
> + pos2 = page.evaluate(
> + "document.getElementById('crosshair_line').getAttribute('x1')"
> + )
> + assert pos1 == pos2
> + page.eval_on_selector(
> + "#chart",
> + "el => el.dispatchEvent(new MouseEvent('mouseleave', {bubbles: true})
)",
> + )
> + line_display = page.evaluate(
> + "document.getElementById('crosshair_line').style.display"
> + )
> + assert line_display != "none"
> + page.eval_on_selector(
> + "#chart",
> + "el => { const r = el.getBoundingClientRect(); el.dispatchEvent(new M
ouseEvent('click', {clientX: r.left + r.width/2, clientY: r.top + r.height/2, bu
bbles: true})); }",
> + )
> + line_display = page.evaluate(
> + "document.getElementById('crosshair_line').style.display"
> + )
> + assert line_display == "none"
> *** End Patch
> PATCH
Success. Updated the following files:
M tests/test_web.py
(scubaduck) root@09b91c3ec8d3:/workspace/scubaduck#
I'll review the patch details to understand the crosshair test better.
(scubaduck) root@09b91c3ec8d3:/workspace/scubaduck# grep -n "crosshair_freeze" -
n tests/test_web.py
308:def test_timeseries_crosshair_freeze(page: Any, server_url: str) -> None:
(scubaduck) root@09b91c3ec8d3:/workspace/scubaduck#
Opening lines 302-318 to make sure the patch is correctly applied.
_web.py
width = page.evaluate(
"getComputedStyle(document.querySelector('#chart path')).strokeWidth"
)
assert "2.5" in width
color = page.evaluate(
"getComputedStyle(document.querySelector('#legend .legend-item')).backgr
oundColor"
)
assert "221, 221, 221" in color
def test_timeseries_crosshair(page: Any, server_url: str) -> None:
page.goto(server_url)
page.wait_for_selector("#graph_type", state="attached")
select_value(page, "#graph_type", "timeseries")
page.evaluate("window.lastResults = undefined")
page.click("text=Dive")
page.wait_for_function("window.lastResults !== undefined")
page.wait_for_selector("#chart path", state="attached")
page.eval_on_selector(
"#chart",
"el => { const r = el.getBoundingClientRect(); el.dispatchEvent(new Mous
eEvent('mousemove', {clientX: r.left + r.width/2, clientY: r.top + r.height/2, b
ubbles: true})); }",
)
line_display = page.evaluate(
"document.getElementById('crosshair_line').style.display"
)
assert line_display != "none"
count = page.eval_on_selector_all("#crosshair_dots circle", "els => els.leng
th")
assert count > 0
page.eval_on_selector(
"#chart",
"el => el.dispatchEvent(new MouseEvent('mouseleave', {bubbles: true}))",
)
line_display = page.evaluate(
"document.getElementById('crosshair_line').style.display"
)
assert line_display == "none"
def test_timeseries_crosshair_freeze(page: Any, server_url: str) -> None:
page.goto(server_url)
page.wait_for_selector("#graph_type", state="attached")
select_value(page, "#graph_type", "timeseries")
page.evaluate("window.lastResults = undefined")
page.click("text=Dive")
page.wait_for_function("window.lastResults !== undefined")
page.wait_for_selector("#chart path", state="attached")
page.eval_on_selector(
"#chart",
"el => { const r = el.getBoundingClientRect(); el.dispatchEvent(new Mous
eEvent('mousemove', {clientX: r.left + r.width/2, clientY: r.top + r.height/2, b
ubbles: true})); }",
)
page.eval_on_selector(
"#chart",
"el => { const r = el.getBoundingClientRect(); el.dispatchEvent(new Mous
eEvent('click', {clientX: r.left + r.width/2, clientY: r.top + r.height/2, bubbl
es: true})); }",
)
line_display = page.evaluate(
"document.getElementById('crosshair_line').style.display"
(scubaduck) root@09b91c3ec8d3:/workspace/scubaduck#
Let me continue scrolling to capture everything.
"document.getElementById('crosshair_line').style.display"
)
assert line_display != "none"
pos1 = page.evaluate(
"document.getElementById('crosshair_line').getAttribute('x1')"
)
page.eval_on_selector(
"#chart",
"el => { const r = el.getBoundingClientRect(); el.dispatchEvent(new Mous
eEvent('mousemove', {clientX: r.left + r.width/4, clientY: r.top + r.height/2, b
ubbles: true})); }",
)
pos2 = page.evaluate(
"document.getElementById('crosshair_line').getAttribute('x1')"
)
assert pos1 == pos2
page.eval_on_selector(
"#chart",
"el => el.dispatchEvent(new MouseEvent('mouseleave', {bubbles: true}))",
)
line_display = page.evaluate(
"document.getElementById('crosshair_line').style.display"
)
assert line_display != "none"
page.eval_on_selector(
"#chart",
"el => { const r = el.getBoundingClientRect(); el.dispatchEvent(new Mous
eEvent('click', {clientX: r.left + r.width/2, clientY: r.top + r.height/2, bubbl
es: true})); }",
)
line_display = page.evaluate(
"document.getElementById('crosshair_line').style.display"
)
assert line_display == "none"
def test_timeseries_auto_timezone(browser: Any, server_url: str) -> None:
context = browser.new_context(timezone_id="America/New_York")
page = context.new_page()
page.goto(server_url)
page.wait_for_selector("#graph_type", state="attached")
select_value(page, "#graph_type", "timeseries")
page.evaluate("window.lastResults = undefined")
page.click("text=Dive")
page.wait_for_function("window.lastResults !== undefined")
path = page.get_attribute("#chart path", "d")
context.close()
assert path is not None
coords = [float(p.split(" ")[1]) for p in path.replace("M", "L").split("L")[
1:]]
assert max(coords) > min(coords)
def test_timeseries_multi_series(page: Any, server_url: str) -> None:
page.goto(server_url)
page.wait_for_selector("#graph_type", state="attached")
select_value(page, "#graph_type", "timeseries")
page.click("text=Columns")
page.click("text=Add Derived")
expr = page.query_selector("#derived_list .derived textarea")
assert expr
(scubaduck) root@09b91c3ec8d3:/workspace/scubaduck#
I'll run Ruff format to check for trailing spaces and other formatting issues.
(scubaduck) root@09b91c3ec8d3:/workspace/scubaduck# ruff format scubaduck/static
/js/timeseries_chart.js tests/test_web.py >/tmp/format.log && tail -n 20 /tmp/fo
rmat.log
error: Failed to parse scubaduck/static/js/timeseries_chart.js:1:5: Simple state
ments must be separated by newlines or semicolons
(scubaduck) root@09b91c3ec8d3:/workspace/scubaduck#
Ruff should only format Python files, so I'll run it only on tests/test_web.py.
(scubaduck) root@09b91c3ec8d3:/workspace/scubaduck# ruff format tests/test_web.p
y >/tmp/format.log && tail -n 20 /tmp/format.log
1 file left unchanged
(scubaduck) root@09b91c3ec8d3:/workspace/scubaduck#
Tests are formatted, so I'll run ruff to ensure everything is linted properly.
(scubaduck) root@09b91c3ec8d3:/workspace/scubaduck# ruff check >/tmp/ruff.log &&
tail -n 20 /tmp/ruff.log
All checks passed!
(scubaduck) root@09b91c3ec8d3:/workspace/scubaduck#
Running pyright for type checking to ensure everything is properly typed.
(scubaduck) root@09b91c3ec8d3:/workspace/scubaduck# pyright >/tmp/pyright.log &&
tail -n 20 /tmp/pyright.log
0 errors, 0 warnings, 0 informations
0 errors, 0 warnings, 0 informations
(scubaduck) root@09b91c3ec8d3:/workspace/scubaduck#
I'll execute the tests using pytest
as required by the instructions.
(scubaduck) root@09b91c3ec8d3:/workspace/scubaduck# pytest -q >/tmp/pytest.log &
& tail -n 20 /tmp/pytest.log
bringing up nodes...
bringing up nodes...
........................................................................ [ 84%]
............. [100%]
85 passed in 11.55s
(scubaduck) root@09b91c3ec8d3:/workspace/scubaduck#
All tests passed! Now, I'll take a look at the log for details.
(scubaduck) root@09b91c3ec8d3:/workspace/scubaduck# cat /tmp/pytest.log
bringing up nodes...
bringing up nodes...
........................................................................ [ 84%]
............. [100%]
85 passed in 11.55s
(scubaduck) root@09b91c3ec8d3:/workspace/scubaduck#
Time to commit the changes I made.
(scubaduck) root@09b91c3ec8d3:/workspace/scubaduck# git status --short
M scubaduck/static/js/timeseries_chart.js
M tests/test_web.py
(scubaduck) root@09b91c3ec8d3:/workspace/scubaduck#
Time to stage everything and commit my changes.
(scubaduck) root@09b91c3ec8d3:/workspace/scubaduck# git add scubaduck/static/js/
timeseries_chart.js tests/test_web.py
(scubaduck) root@09b91c3ec8d3:/workspace/scubaduck# git commit -m "feat(web): al
low freezing timeseries crosshair" && git status --short
[work 5376849] feat(web): allow freezing timeseries crosshair
2 files changed, 65 insertions(+), 3 deletions(-)
(scubaduck) root@09b91c3ec8d3:/workspace/scubaduck# git status --short
(scubaduck) root@09b91c3ec8d3:/workspace/scubaduck#
I'll grab lines for timeseries JS changes involving the crosshair freeze and event handlers.
112 crosshairDots,
113 seriesEls: {},
114 bucketPixels: [],
115 xScale: null,
116 yScale: null,
117 selected: null,
118 frozen: false
119 };
120
121 const intervals = [
122 {unit: 'second', step: 1, ms: 1000},
123 {unit: 'second', step: 2, ms: 2000},
124 {unit: 'second', step: 5, ms: 5000},
125 {unit: 'second', step: 10, ms: 10000},
126 {unit: 'second', step: 15, ms: 15000},
127 {unit: 'second', step: 30, ms: 30000},
128 {unit: 'minute', step: 1, ms: 60000},
129 {unit: 'minute', step: 2, ms: 120000},
130 {unit: 'minute', step: 5, ms: 300000},
(scubaduck) root@09b91c3ec8d3:/workspace/scubaduck#
I’m continuing with event handlers and similar tasks.
(scubaduck) root@09b91c3ec8d3:/workspace/scubaduck# nl -ba scubaduck/static/js/t
imeseries_chart.js | sed -n '368,460p'
368 render();
369
370 function hideCrosshair() {
371 if (currentChart.frozen) return;
372 crosshairLine.style.display = 'none';
373 crosshairDots.style.display = 'none';
374 crosshairDots.innerHTML = '';
375 Object.values(currentChart.seriesEls).forEach(el => {
376 el.valueEl.textContent = '';
377 });
378 if (currentChart.selected) {
379 currentChart.seriesEls[currentChart.selected].highlight(false);
380 currentChart.selected = null;
381 }
382 }
383
384 function updateCrosshair(e) {
385 const rect = svg.getBoundingClientRect();
386 const x = e.clientX - rect.left;
387 const y = e.clientY - rect.top;
388 const pixels = currentChart.bucketPixels;
389 if (!pixels.length) return;
390 let idx = 0;
391 let dist = Math.abs(pixels[0] - x);
392 for (let i = 1; i < pixels.length; i++) {
393 const d = Math.abs(pixels[i] - x);
394 if (d < dist) {
395 dist = d;
396 idx = i;
397 }
398 }
399 const bucket = currentChart.buckets[idx];
400 const xPix = pixels[idx];
401 crosshairLine.setAttribute('x1', xPix);
402 crosshairLine.setAttribute('x2', xPix);
403 crosshairLine.setAttribute('y1', currentChart.yScale(currentChart.ma
xY));
404 crosshairLine.setAttribute('y2', currentChart.yScale(currentChart.mi
nY));
405 crosshairLine.style.display = 'block';
406 crosshairDots.style.display = 'block';
407 crosshairDots.innerHTML = '';
408 const options = [];
409 Object.keys(currentChart.series).forEach(key => {
410 const vals = currentChart.series[key];
411 let v = vals[bucket];
412 if (v === undefined && currentChart.fill !== '0') {
413 currentChart.seriesEls[key].valueEl.textContent = '';
414 return;
415 }
416 if (v === undefined) v = 0;
417 currentChart.seriesEls[key].valueEl.textContent = formatNumber(v);
418 const yPix = currentChart.yScale(v);
419 const dot = document.createElementNS('http://www.w3.org/2000/svg',
'circle');
420 dot.setAttribute('cx', xPix);
421 dot.setAttribute('cy', yPix);
422 dot.setAttribute('r', '3');
423 dot.setAttribute('fill', currentChart.seriesEls[key].color);
424 crosshairDots.appendChild(dot);
425 options.push({ key, y: yPix });
426 });
427 if (options.length) {
428 let best = options[0];
429 let bestDist = Math.abs(best.y - y);
430 for (let i = 1; i < options.length; i++) {
431 const d = Math.abs(options[i].y - y);
432 if (d < bestDist) {
433 best = options[i];
434 bestDist = d;
435 }
436 }
437 if (currentChart.selected && currentChart.selected !== best.key) {
438 currentChart.seriesEls[currentChart.selected].highlight(false);
439 }
440 currentChart.seriesEls[best.key].highlight(true);
441 currentChart.selected = best.key;
442 }
443 }
444
445 svg.addEventListener('mouseleave', hideCrosshair);
446 svg.addEventListener('mousemove', e => {
447 if (currentChart.frozen) return;
448 updateCrosshair(e);
449 });
450
451 svg.addEventListener('click', e => {
452 if (currentChart.frozen) {
453 currentChart.frozen = false;
454 hideCrosshair();
455 } else {
456 updateCrosshair(e);
457 currentChart.frozen = true;
458 }
459 });
460
(scubaduck) root@09b91c3ec8d3:/workspace/scubaduck#
I'll grab the lines related to the tests as well.
(scubaduck) root@09b91c3ec8d3:/workspace/scubaduck# nl -ba tests/test_web.py | s
ed -n '300,364p'
300 "el => el.dispatchEvent(new MouseEvent('mouseleave', {bubbles: t
rue}))",
301 )
302 line_display = page.evaluate(
303 "document.getElementById('crosshair_line').style.display"
304 )
305 assert line_display == "none"
306
307
308 def test_timeseries_crosshair_freeze(page: Any, server_url: str) -> None
:
309 page.goto(server_url)
310 page.wait_for_selector("#graph_type", state="attached")
311 select_value(page, "#graph_type", "timeseries")
312 page.evaluate("window.lastResults = undefined")
313 page.click("text=Dive")
314 page.wait_for_function("window.lastResults !== undefined")
315 page.wait_for_selector("#chart path", state="attached")
316 page.eval_on_selector(
317 "#chart",
318 "el => { const r = el.getBoundingClientRect(); el.dispatchEvent(
new MouseEvent('mousemove', {clientX: r.left + r.width/2, clientY: r.top + r.hei
ght/2, bubbles: true})); }",
319 )
320 page.eval_on_selector(
321 "#chart",
322 "el => { const r = el.getBoundingClientRect(); el.dispatchEvent(
new MouseEvent('click', {clientX: r.left + r.width/2, clientY: r.top + r.height/
2, bubbles: true})); }",
323 )
324 line_display = page.evaluate(
325 "document.getElementById('crosshair_line').style.display"
326 )
327 assert line_display != "none"
328 pos1 = page.evaluate("document.getElementById('crosshair_line').getA
ttribute('x1')")
329 page.eval_on_selector(
330 "#chart",
331 "el => { const r = el.getBoundingClientRect(); el.dispatchEvent(
new MouseEvent('mousemove', {clientX: r.left + r.width/4, clientY: r.top + r.hei
ght/2, bubbles: true})); }",
332 )
333 pos2 = page.evaluate("document.getElementById('crosshair_line').getA
ttribute('x1')")
334 assert pos1 == pos2
335 page.eval_on_selector(
336 "#chart",
337 "el => el.dispatchEvent(new MouseEvent('mouseleave', {bubbles: t
rue}))",
338 )
339 line_display = page.evaluate(
340 "document.getElementById('crosshair_line').style.display"
341 )
342 assert line_display != "none"
343 page.eval_on_selector(
344 "#chart",
345 "el => { const r = el.getBoundingClientRect(); el.dispatchEvent(
new MouseEvent('click', {clientX: r.left + r.width/2, clientY: r.top + r.height/
2, bubbles: true})); }",
346 )
347 line_display = page.evaluate(
348 "document.getElementById('crosshair_line').style.display"
349 )
350 assert line_display == "none"
351
352
353 def test_timeseries_auto_timezone(browser: Any, server_url: str) -> None
:
354 context = browser.new_context(timezone_id="America/New_York")
355 page = context.new_page()
356 page.goto(server_url)
357 page.wait_for_selector("#graph_type", state="attached")
358 select_value(page, "#graph_type", "timeseries")
359 page.evaluate("window.lastResults = undefined")
360 page.click("text=Dive")
361 page.wait_for_function("window.lastResults !== undefined")
362 path = page.get_attribute("#chart path", "d")
363 context.close()
364 assert path is not None
(scubaduck) root@09b91c3ec8d3:/workspace/scubaduck#
I’ll write the PR message with proper citations and line references for clarity.