fix: auto-register devices + refresh CSV (140 new rows) #9

Merged
kianiadee merged 1 commit from quality-program-2026-04-12 into main 2026-04-21 09:30:14 +00:00
Owner

Closes the FK-violation loop on /pushalarm. CSV import patched to INSERT new devices. Webhook auto-registers unknown IMEIs as stub devices (status=unknown). CSV refreshed to Apr 21 version.

Live DB already updated (63→201 devices). Webhook patch needs Coolify redeploy.

Closes the FK-violation loop on /pushalarm. CSV import patched to INSERT new devices. Webhook auto-registers unknown IMEIs as stub devices (status=unknown). CSV refreshed to Apr 21 version. Live DB already updated (63→201 devices). Webhook patch needs Coolify redeploy.
kianiadee added 1 commit 2026-04-21 09:29:45 +00:00
fix: auto-register devices on push + allow CSV import to insert new rows
Some checks failed
Static Analysis / static (push) Waiting to run
Tests / test (push) Waiting to run
Static Analysis / static (pull_request) Has been cancelled
Tests / test (pull_request) Has been cancelled
257643cae2
Three changes that together close the FK-violation loop on /pushalarm:

1. import_drivers_csv.py: when an IMEI is in the CSV but not in
   tracksolid.devices, INSERT a new row instead of skipping. Unblocks
   the 140 X3/JC400P devices listed as a HIGH open item in CLAUDE.md §10.

2. webhook_receiver_rev.py: new _ensure_device() helper upserts a stub
   devices row (status='unknown') before inserting an alarm. Handles the
   third class of devices — not in API sync, not in CSV (e.g. the
   X3-63282 Kampala device flagged in CLAUDE.md §10).

3. CSV refreshed from Downloads (Apr 21 version, 140 active rows).

Also fixes alarm error log previously showing "None" (read deviceImei
instead of the integration push's imei field).

CSV import already applied live on the instance (63 → 201 devices).
Webhook patch requires a Coolify redeploy to pick up _ensure_device().

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
kianiadee merged commit e5c9d0f4c4 into main 2026-04-21 09:30:14 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: kianiadee/tracksolid_timescale_grafana_prod#9
No description provided.