mirror of
https://git.ianrenton.com/ian/spothole.git
synced 2026-08-13 16:07:30 +00:00
Fix extra duplicates showing for spots and alerts
This commit is contained in:
+8
-11
@@ -113,18 +113,15 @@ class Alert:
|
||||
if self.sig_refs and len(self.sig_refs) > 0 and self.sig_refs[0] and not self.sig:
|
||||
self.sig = self.sig_refs[0].sig
|
||||
|
||||
# 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
|
||||
# apart from that they were retrieved from the API at different times. Note that the simple Python hash()
|
||||
# function includes a seed randomly generated at runtime; this is therefore not consistent between runs. But we
|
||||
# use diskcache to store our data between runs, so we use SHA256 which does not include this random element.
|
||||
# The ID is computed before the online lookups below so that it is stable regardless of whether credentials
|
||||
# are provided, allowing the enriched API response to be matched to the stored alert by ID.
|
||||
# Create an ID based on the source and source ID if possible, as these guaranee uniqueness. If there is no
|
||||
# source ID, use a combination of callsign and start time. Excluding things like the comment here allows for
|
||||
# user updates of their alert comments without duplicating in the system.
|
||||
if not self.id:
|
||||
self_copy = copy.deepcopy(self)
|
||||
self_copy.received_time = 0
|
||||
self_copy.received_time_iso = ""
|
||||
self.id = hashlib.sha256(str(self_copy).encode("utf-8")).hexdigest()
|
||||
if self.source and self.source_id:
|
||||
self.id = hashlib.sha256(str({"s": self.source, "sid": self.source_id}).encode("utf-8")).hexdigest()
|
||||
else:
|
||||
self.id = hashlib.sha256(
|
||||
str({"s": self.source, "c": self.dx_calls, "t": self.start_time}).encode("utf-8")).hexdigest()
|
||||
|
||||
# DX operator name lookup, using QRZ.com/HamQTH.
|
||||
if self.dx_calls and not self.dx_names:
|
||||
|
||||
Reference in New Issue
Block a user