fix(sfm): a download the store already holds is found by its Blastware name, not only its time (#8 review)
persist_download checked 'already stored' on the unit's 0C time only, but a
histogram's row is stored at its file's time, a second earlier on most
histograms (#51): K441LTOK.QZ0 decodes to 16:06:34, its 0C says 16:06:35. So a
live download of an event the watcher had imported missed the check and
re-stored it -- UPSERTing over the watcher's row (Blastware's ZC frequencies and
vector sum lost) and rewriting its sidecar as sfm-live -- and every repeat live
download rewrote the files again.
New SeismoDb.find_event_by_blastware_name(): the row stored under the same
Blastware name (the event's second, per blastware_filename_time; the rule
_restamp_by_file uses), matching a direct name to the call-in copy's W/H name.
Any other name matches nothing. Also two comments from 9492e49 that said the
opposite of the code (the unit's peaks are overlaid; source.kind is a parameter).
Store consequence: none for existing rows; no schema change, no migration.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SyJ2ip3Krb6dtdv2cXua44
This commit is contained in:
1 parent
dbd8a91661
commit
3a1d34ae92
4 files changed
+71
-3
No files matched your search
@@ -808,6 +808,28 @@ class SeismoDb:
|
||||
).fetchone()
|
||||
return dict(row) if row else None
|
||||
|
||||
def find_event_by_blastware_name(self, serial: str, filename: str) -> Optional[dict]:
|
||||
"""The row stored under `filename`'s Blastware name, or None.
|
||||
|
||||
A Blastware name encodes the serial and the event's second
|
||||
(`blastware_filename_time`), so the same name is the same event -- the
|
||||
rule `_restamp_by_file` uses. A direct download is `<stem>.<AB>0` and
|
||||
Blastware's call-in copy of the same event `<stem>.<AB>0W` / `H`; all
|
||||
three forms match. Any other name ("imported.bw") matches nothing.
|
||||
"""
|
||||
if blastware_filename_time(filename) is None:
|
||||
return None
|
||||
base = filename.upper()
|
||||
if len(base.rsplit(".", 1)[-1]) == 4:
|
||||
base = base[:-1]
|
||||
with self._connect() as conn:
|
||||
row = conn.execute(
|
||||
"SELECT * FROM events WHERE serial = ? AND UPPER(blastware_filename) IN (?, ?, ?) "
|
||||
"ORDER BY rowid LIMIT 1",
|
||||
(serial, base, base + "W", base + "H"),
|
||||
).fetchone()
|
||||
return dict(row) if row else None
|
||||
|
||||
def query_events(
|
||||
self,
|
||||
serial: Optional[str] = None,
|
||||
|
||||
Reference in new issue
Block a user