From b5bbde8acbd93e6310cfc991a50b92611e8d2337 Mon Sep 17 00:00:00 2001 From: Per Magnus Petersen Date: Thu, 17 Sep 2026 14:49:25 +0200 Subject: [PATCH] Show midnight price change in page title --- Makefile | 9 ++++++++- app/main.py | 40 ++++++++++++++++++++++++++++++++++++---- tests/test_health.py | 8 +++++++- 3 files changed, 51 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 7025c43..2ad0032 100644 --- a/Makefile +++ b/Makefile @@ -4,8 +4,9 @@ export VENV := .venv UVICORN := $(VENV)/bin/uvicorn TEST_DEPS := $(VENV)/.test-deps +K3S_BTCDATA_PORT := 4100 -.PHONY: clean run run-local run-citadel tailwind test venv +.PHONY: clean run run-local run-citadel run-k3s tailwind test venv venv: $(UVICORN) @@ -26,6 +27,12 @@ run-local: venv run-citadel: venv BTCDATA_URL=$(BTCDATA_URL) $(UVICORN) app.main:app --host 0.0.0.0 --port 4000 --reload +run-k3s: venv + kubectl -n btcdata port-forward service/btcdata $(K3S_BTCDATA_PORT):4101 & \ + port_forward_pid=$$!; \ + trap 'kill $$port_forward_pid' EXIT INT TERM; \ + BTCDATA_URL=http://127.0.0.1:$(K3S_BTCDATA_PORT) $(UVICORN) app.main:app --host 0.0.0.0 --port 4000 --reload + tailwind: npm run css:watch diff --git a/app/main.py b/app/main.py index 243a53c..b99bf38 100644 --- a/app/main.py +++ b/app/main.py @@ -78,14 +78,45 @@ HOME_HTML = """\ @@ -250,7 +282,7 @@ def price_json_to_html(text: str) -> str: formatted_price = f'${da_fmt(",.2f", p)}' html = ( - f'
' + f'
' '
' '
' f'

{formatted_price}

' diff --git a/tests/test_health.py b/tests/test_health.py index fbc6517..fd1500c 100644 --- a/tests/test_health.py +++ b/tests/test_health.py @@ -37,7 +37,12 @@ def test_home_updates_title_from_latest_price(): assert response.status_code == 200 assert "new MutationObserver(updateTitleFromPrice)" in response.text - assert "document.title = price + ' | BTC Price'" in response.text + assert "currentPrice - midnightPrice" in response.text + assert "document.title = price + ' | ' + formattedChange" in response.text + assert '

BTC Price

' in response.text + assert "page-title" not in response.text + assert "formatPriceChange(change)" in response.text + assert "midnight.setHours(0, 0, 0, 0)" in response.text def test_price_fragment_exposes_formatted_price_for_title(): @@ -46,6 +51,7 @@ def test_price_fragment_exposes_formatted_price_for_title(): ) assert 'data-title-price="$67.432,10"' in html + assert 'data-price-value="67432.1"' in html assert ">$67.432,10

" in html