mirror of
https://git.ianrenton.com/ian/spothole.git
synced 2026-08-06 02:21:42 +00:00
Refactor of caching & data storage part 14 #118
This commit is contained in:
+9
-10
@@ -7,7 +7,7 @@ from datetime import datetime, timedelta
|
||||
|
||||
import pytz
|
||||
|
||||
from core.call_lookup_helper import lookup_helper
|
||||
from core.call_lookup_helper import get_call_info
|
||||
from core.sig_lookup_helper import populate_missing_sig_ref_info
|
||||
from core.utils import get_flag_for_dxcc
|
||||
|
||||
@@ -86,16 +86,17 @@ class Alert:
|
||||
|
||||
# DX country, continent, zones etc. from callsign. CQ/ITU zone are better looked up with a location but we don't
|
||||
# have a real location for alerts.
|
||||
call_info = get_call_info(self.dx_calls[0], credentials)
|
||||
if self.dx_calls and self.dx_calls[0] and not self.dx_country:
|
||||
self.dx_country = lookup_helper.infer_country_from_callsign(self.dx_calls[0], credentials)
|
||||
self.dx_country = call_info.country
|
||||
if self.dx_calls and self.dx_calls[0] and not self.dx_continent:
|
||||
self.dx_continent = lookup_helper.infer_continent_from_callsign(self.dx_calls[0], credentials)
|
||||
self.dx_continent = call_info.continent
|
||||
if self.dx_calls and self.dx_calls[0] and not self.dx_cq_zone:
|
||||
self.dx_cq_zone = lookup_helper.infer_cq_zone_from_callsign(self.dx_calls[0], credentials)
|
||||
self.dx_cq_zone = call_info.cq_zone
|
||||
if self.dx_calls and self.dx_calls[0] and not self.dx_itu_zone:
|
||||
self.dx_itu_zone = lookup_helper.infer_itu_zone_from_callsign(self.dx_calls[0], credentials)
|
||||
self.dx_itu_zone = call_info.itu_zone
|
||||
if self.dx_calls and self.dx_calls[0] and not self.dx_dxcc_id:
|
||||
self.dx_dxcc_id = lookup_helper.infer_dxcc_id_from_callsign(self.dx_calls[0], credentials)
|
||||
self.dx_dxcc_id = call_info.dxcc_id
|
||||
if self.dx_dxcc_id and not self.dx_flag:
|
||||
self.dx_flag = get_flag_for_dxcc(self.dx_dxcc_id)
|
||||
|
||||
@@ -124,12 +125,10 @@ class Alert:
|
||||
self_copy.received_time_iso = ""
|
||||
self.id = hashlib.sha256(str(self_copy).encode("utf-8")).hexdigest()
|
||||
|
||||
# DX operator details lookup, using QRZ.com/HamQTH. This should be the last resort compared to taking the data
|
||||
# from the actual alerting service, e.g. we don't want to accidentally use a user's QRZ.com home lat/lon
|
||||
# instead of the one from the park reference they're at.
|
||||
# DX operator name lookup, using QRZ.com/HamQTH.
|
||||
if self.dx_calls and not self.dx_names:
|
||||
self.dx_names = list(
|
||||
map(lambda c: lookup_helper.infer_name_from_callsign_online_lookup(c, credentials), self.dx_calls))
|
||||
map(lambda c: get_call_info(c, credentials).name, self.dx_calls))
|
||||
|
||||
except Exception as e:
|
||||
logging.error("Exception while inferring missing data from spot", e, exc_info=True)
|
||||
|
||||
Reference in New Issue
Block a user