feat: checkbox batch trip delete on the Pi (local-only)

- Pi history page gets a select checkbox column + 'Delete selected' button
  (mirrors the server UI)
- POST /api/trips/delete batch endpoint
- app_sql.delete_trips_batch() + deleted_trip_markers table so a later trip
  rebuild can't resurrect locally-deleted trips
- Deletion is local-only: raw tracking rows are kept and the remote server
  is never notified (it keeps its archival copy recomputed from uploaded rows)
This commit is contained in:
Mathieu Moran
2026-08-15 16:55:30 -04:00
parent c9d36cca33
commit 99035e86ee
4 changed files with 85 additions and 2 deletions
+30
View File
@@ -76,6 +76,36 @@ class TripSqlTest(unittest.TestCase):
self.assertEqual(rebuilt[0], original[0])
def test_deleted_trip_is_not_resurrected_by_rebuild(self):
started = datetime(2026, 1, 1, 8)
self.insert_motion(1, 160, started, 45.5)
self.insert_motion(161, 10, started + timedelta(minutes=30), 45.6)
app_sql.refresh_trips(force=True)
self.assertEqual(
self.conn.execute("SELECT COUNT(*) FROM trips").fetchone()[0], 2
)
trip_ids = [
row[0]
for row in self.conn.execute("SELECT id FROM trips ORDER BY id").fetchall()
]
self.assertEqual(app_sql.delete_trips_batch(trip_ids), 2)
self.assertEqual(
self.conn.execute("SELECT COUNT(*) FROM trips").fetchone()[0], 0
)
self.assertEqual(
self.conn.execute(
"SELECT COUNT(*) FROM deleted_trip_markers"
).fetchone()[0],
2,
)
# A full rebuild must not resurrect locally-deleted trips.
app_sql.refresh_trips(force=True)
self.assertEqual(
self.conn.execute("SELECT COUNT(*) FROM trips").fetchone()[0], 0
)
if __name__ == "__main__":
unittest.main()