From 5a6fc19ab5d96999e7df064eb81e9e7e804924da Mon Sep 17 00:00:00 2001 From: Ian Renton Date: Wed, 2 Sep 2026 07:46:02 +0100 Subject: [PATCH] dxstats.py now uses is_ham_hf flag on bands list instead of providing its own. Closes #139 --- server/handlers/api/dxstats.py | 7 ++++--- templates/add_spot.html | 2 +- templates/alerts.html | 2 +- templates/bands.html | 4 ++-- templates/base.html | 10 +++++----- templates/conditions.html | 2 +- templates/map.html | 4 ++-- templates/spots.html | 4 ++-- templates/status.html | 2 +- 9 files changed, 19 insertions(+), 18 deletions(-) diff --git a/server/handlers/api/dxstats.py b/server/handlers/api/dxstats.py index 67519d8..b4d479f 100644 --- a/server/handlers/api/dxstats.py +++ b/server/handlers/api/dxstats.py @@ -9,6 +9,7 @@ import tornado from tornado import httputil from tornado.web import Application +from core.constants import BANDS from core.enums import Continent from core.prometheus_metrics_handler import api_requests_counter from core.utils import safe_json_dumps @@ -16,7 +17,7 @@ from core.utils import safe_json_dumps logger = logging.getLogger(__name__) CONTINENTS = [c.value for c in Continent] -BANDS = ["160m", "80m", "60m", "40m", "30m", "20m", "17m", "15m", "12m", "10m", "6m"] +HF_BANDS = [b.name for b in BANDS if b.is_ham_hf] class APIDxStatsHandler(tornado.web.RequestHandler): @@ -52,11 +53,11 @@ class APIDxStatsHandler(tornado.web.RequestHandler): continue if not spot.time or spot.time < one_hour_ago: continue - if spot.de_continent in CONTINENTS and spot.dx_continent in CONTINENTS and spot.band in BANDS: + if spot.de_continent in CONTINENTS and spot.dx_continent in CONTINENTS and spot.band in HF_BANDS: counts[spot.de_continent, spot.dx_continent, spot.band] += 1 result = { - de: {dx: {band: counts[de, dx, band] for band in BANDS} for dx in CONTINENTS} for de in CONTINENTS + de: {dx: {band: counts[de, dx, band] for band in HF_BANDS} for dx in CONTINENTS} for de in CONTINENTS } self.write(json.dumps(result)) diff --git a/templates/add_spot.html b/templates/add_spot.html index 0d5fd55..6f76b99 100644 --- a/templates/add_spot.html +++ b/templates/add_spot.html @@ -76,7 +76,7 @@ - + diff --git a/templates/alerts.html b/templates/alerts.html index 789b6ab..8def2e5 100644 --- a/templates/alerts.html +++ b/templates/alerts.html @@ -84,7 +84,7 @@ - + diff --git a/templates/bands.html b/templates/bands.html index aa63a5b..c5bfb6c 100644 --- a/templates/bands.html +++ b/templates/bands.html @@ -76,8 +76,8 @@ - - + + diff --git a/templates/base.html b/templates/base.html index 7c1edea..e22274e 100644 --- a/templates/base.html +++ b/templates/base.html @@ -1,6 +1,6 @@ {% extends "skeleton.html" %} {% block head_extra %} - + @@ -15,10 +15,10 @@ window.fetchEventSource = fetchEventSource; - - - - + + + + {% end %} {% block body %}
diff --git a/templates/conditions.html b/templates/conditions.html index 3725e4e..b37f3c7 100644 --- a/templates/conditions.html +++ b/templates/conditions.html @@ -284,7 +284,7 @@
- + diff --git a/templates/map.html b/templates/map.html index 13bc1e5..e8c97bf 100644 --- a/templates/map.html +++ b/templates/map.html @@ -113,8 +113,8 @@ const CARTODB_API_KEY = "{{ web_ui_options.get('cartodb_api_key', '') }}"; - - + + diff --git a/templates/spots.html b/templates/spots.html index 5a8a8ce..625fe74 100644 --- a/templates/spots.html +++ b/templates/spots.html @@ -113,8 +113,8 @@ - - + + diff --git a/templates/status.html b/templates/status.html index f598bdd..64199d6 100644 --- a/templates/status.html +++ b/templates/status.html @@ -86,7 +86,7 @@ - +