mirror of
https://git.ianrenton.com/ian/spothole.git
synced 2026-09-20 14:27:42 +00:00
Start converting some enum-like strings to proper enums
This commit is contained in:
@@ -9,15 +9,14 @@ import tornado
|
||||
from tornado import httputil
|
||||
from tornado.web import Application
|
||||
|
||||
from core.enums import Continent
|
||||
from core.prometheus_metrics_handler import api_requests_counter
|
||||
from core.utils import safe_json_dumps
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
CONTINENTS = ["EU", "NA", "SA", "AS", "AF", "OC", "AN"]
|
||||
CONTINENTS = [c.value for c in Continent]
|
||||
BANDS = ["160m", "80m", "60m", "40m", "30m", "20m", "17m", "15m", "12m", "10m", "6m"]
|
||||
CONTINENTS_SET = frozenset(CONTINENTS)
|
||||
BANDS_SET = frozenset(BANDS)
|
||||
|
||||
|
||||
class APIDxStatsHandler(tornado.web.RequestHandler):
|
||||
@@ -53,11 +52,7 @@ class APIDxStatsHandler(tornado.web.RequestHandler):
|
||||
continue
|
||||
if not spot.time or spot.time < one_hour_ago:
|
||||
continue
|
||||
if (
|
||||
spot.de_continent in CONTINENTS_SET
|
||||
and spot.dx_continent in CONTINENTS_SET
|
||||
and spot.band in BANDS_SET
|
||||
):
|
||||
if spot.de_continent in CONTINENTS and spot.dx_continent in CONTINENTS and spot.band in BANDS:
|
||||
counts[spot.de_continent, spot.dx_continent, spot.band] += 1
|
||||
|
||||
result = {
|
||||
|
||||
@@ -8,14 +8,8 @@ from tornado import httputil
|
||||
from tornado.web import Application
|
||||
|
||||
from core.config import ALLOW_SPOTTING, MAX_SPOT_AGE
|
||||
from core.constants import (
|
||||
ALL_MODES,
|
||||
BANDS,
|
||||
CONTINENTS,
|
||||
MODE_TYPES,
|
||||
PROPAGATION_MODES,
|
||||
SIGS,
|
||||
)
|
||||
from core.constants import ALL_MODES, BANDS, MODE_TYPES, PROPAGATION_MODES, SIGS
|
||||
from core.enums import Continent
|
||||
from core.prometheus_metrics_handler import api_requests_counter
|
||||
from core.utils import safe_json_dumps
|
||||
|
||||
@@ -96,7 +90,7 @@ class APIOptionsHandler(tornado.web.RequestHandler):
|
||||
"spot_providers_enabled_by_default": spot_providers_enabled_by_default,
|
||||
"alert_providers": alert_providers,
|
||||
"callsign_data_providers": callsign_data_providers,
|
||||
"continents": CONTINENTS,
|
||||
"continents": [c.value for c in Continent],
|
||||
"propagation_modes": list(PROPAGATION_MODES.values()),
|
||||
"max_spot_age": MAX_SPOT_AGE,
|
||||
"spot_allowed": ALLOW_SPOTTING,
|
||||
|
||||
Reference in New Issue
Block a user