Skip to content

Commit 7cae1d0

Browse files
authored
Merge pull request #153 from 12urenloop/feat/only-insert-db-baton-detections
refactor(detections): only store detections for which a baton is defined
2 parents fda43fa + d00af2b commit 7cae1d0

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/main/java/telraam/database/daos/DetectionDAO.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,10 @@ INSERT INTO detection (station_id, baton_id, timestamp, rssi, battery, remote_id
3434
int insertAll(@BindBean List<Detection> detection);
3535

3636
@SqlBatch("""
37-
INSERT INTO detection (station_id, baton_id, timestamp, rssi, battery, remote_id, uptime_ms, timestamp_ingestion) \
38-
VALUES (:stationId, (SELECT id FROM baton WHERE mac = :batonMac), :timestamp, :rssi, :battery, :remoteId, :uptimeMs, :timestampIngestion)
37+
INSERT INTO detection (station_id, baton_id, timestamp, rssi, battery, remote_id, uptime_ms, timestamp_ingestion)
38+
SELECT :stationId, b.id, :timestamp, :rssi, :battery, :remoteId, :uptimeMs, :timestampIngestion
39+
FROM baton b
40+
WHERE b.mac = :batonMac
3941
""")
4042
@GetGeneratedKeys({"id", "baton_id"})
4143
@RegisterBeanMapper(Detection.class)

0 commit comments

Comments
 (0)