Allow alerts to have more than one DX callsign, and parse the "as CALL" fields from NG3K. Not yet working #38

This commit is contained in:
Ian Renton
2025-10-10 11:37:59 +01:00
parent 5c3adcdd4d
commit cc816d8662
7 changed files with 47 additions and 32 deletions

View File

@@ -17,10 +17,10 @@ from core.utils import infer_continent_from_callsign, \
class Alert:
# Unique identifier for the alert
id: str = None
# Callsign of the operator that has been alertted
dx_call: str = None
# Name of the operator that has been alertted
dx_name: str = None
# Callsigns of the operators that has been alerted
dx_calls: list = None
# Names of the operators that has been alerted
dx_names: list = None
# Country of the DX operator
dx_country: str = None
# Country flag of the DX operator
@@ -88,24 +88,24 @@ class Alert:
self.received_time_iso = datetime.fromtimestamp(self.received_time, pytz.UTC).isoformat()
# DX country, continent, zones etc. from callsign
if self.dx_call and not self.dx_country:
self.dx_country = infer_country_from_callsign(self.dx_call)
if self.dx_call and not self.dx_continent:
self.dx_continent = infer_continent_from_callsign(self.dx_call)
if self.dx_call and not self.dx_cq_zone:
self.dx_cq_zone = infer_cq_zone_from_callsign(self.dx_call)
if self.dx_call and not self.dx_itu_zone:
self.dx_itu_zone = infer_itu_zone_from_callsign(self.dx_call)
if self.dx_call and not self.dx_dxcc_id:
self.dx_dxcc_id = infer_dxcc_id_from_callsign(self.dx_call)
if self.dx_calls and self.dx_calls[0] and not self.dx_country:
self.dx_country = infer_country_from_callsign(self.dx_calls[0])
if self.dx_calls and self.dx_calls[0] and not self.dx_continent:
self.dx_continent = infer_continent_from_callsign(self.dx_calls[0])
if self.dx_calls and self.dx_calls[0] and not self.dx_cq_zone:
self.dx_cq_zone = infer_cq_zone_from_callsign(self.dx_calls[0])
if self.dx_calls and self.dx_calls[0] and not self.dx_itu_zone:
self.dx_itu_zone = infer_itu_zone_from_callsign(self.dx_calls[0])
if self.dx_calls and self.dx_calls[0] and not self.dx_dxcc_id:
self.dx_dxcc_id = infer_dxcc_id_from_callsign(self.dx_calls[0])
if self.dx_dxcc_id and not self.dx_flag:
self.dx_flag = DXCC_FLAGS[self.dx_dxcc_id]
# DX operator details lookup, using QRZ.com. This should be the last resort compared to taking the data from
# the actual alertting 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.
if self.dx_call and not self.dx_name:
self.dx_name = infer_name_from_callsign(self.dx_call)
if self.dx_calls and not self.dx_names:
self.dx_names = list(map(lambda c: infer_name_from_callsign(c), self.dx_calls))
# Always create an ID based on a hash of every parameter *except* received_time. This is used as the index
# to a map, which as a byproduct avoids us having multiple duplicate copies of the object that are identical