feat(db): insert_events persists shape_* from waveform record

This commit is contained in:
2026-08-22 05:55:25 +00:00
parent a894b001b1
commit 54c4182023
2 changed files with 86 additions and 3 deletions
+17 -3
View File
@@ -426,9 +426,11 @@ class SeismoDb:
device_family,
tran_zc_freq, vert_zc_freq, long_zc_freq, mic_zc_freq,
tran_zc_above_range, vert_zc_above_range,
long_zc_above_range, mic_zc_above_range)
long_zc_above_range, mic_zc_above_range,
shape_crest_factor, shape_near_peak_count,
shape_sample_count, shape_axis)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,
?, ?, ?, ?, ?, ?, ?, ?)
?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
""",
(
self._new_id(), serial, key, session_id, ts,
@@ -456,6 +458,10 @@ class SeismoDb:
(1 if (pv and pv.vert_zc_above_range) else 0),
(1 if (pv and pv.long_zc_above_range) else 0),
(1 if (pv and pv.mic_zc_above_range) else 0),
rec.get("shape_crest_factor"),
rec.get("shape_near_peak_count"),
rec.get("shape_sample_count"),
rec.get("shape_axis"),
),
)
inserted += 1
@@ -505,7 +511,11 @@ class SeismoDb:
tran_zc_above_range = ?,
vert_zc_above_range = ?,
long_zc_above_range = ?,
mic_zc_above_range = ?
mic_zc_above_range = ?,
shape_crest_factor = COALESCE(?, shape_crest_factor),
shape_near_peak_count = COALESCE(?, shape_near_peak_count),
shape_sample_count = COALESCE(?, shape_sample_count),
shape_axis = COALESCE(?, shape_axis)
WHERE serial = ? AND timestamp = ?
""",
(
@@ -533,6 +543,10 @@ class SeismoDb:
(1 if (pv and pv.vert_zc_above_range) else 0),
(1 if (pv and pv.long_zc_above_range) else 0),
(1 if (pv and pv.mic_zc_above_range) else 0),
rec.get("shape_crest_factor") if rec else None,
rec.get("shape_near_peak_count") if rec else None,
rec.get("shape_sample_count") if rec else None,
rec.get("shape_axis") if rec else None,
serial,
ts,
),