Commit 317d1ac
Fix motion activity endpoint returning invalid timestamps after pandas 3.0 upgrade
pandas 3.0 changed DatetimeIndex internal storage from datetime64[ns]
(nanoseconds) to datetime64[us] (microseconds). The motion activity
endpoint in review.py converted DatetimeIndex to epoch seconds using:
df.index = df.index.astype(int) // (10**9)
This assumed nanosecond resolution, dividing by 10^9 to get seconds.
With microsecond resolution the division produces values ~1000x too
small (e.g. 1774785 instead of 1774785600), causing every entry to
have a start_time near zero. The frontend timeline could not match
these timestamps to the visible range, so motion indicator bars
disappeared entirely — despite the underlying recording data being
correct.
Replace the resolution-dependent integer division with pandas
Timedelta arithmetic:
df.index = (df.index - _EPOCH) // _ONE_SECOND
This is resolution-independent (produces correct results on
datetime64[s], [ms], [us], and [ns]), ~148x faster than the
per-element .timestamp() alternative, produces native Python int
types that serialize cleanly to JSON, and is backwards-compatible
with older pandas versions.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>1 parent 148e11a commit 317d1ac
1 file changed
+6
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
43 | 48 | | |
44 | 49 | | |
45 | 50 | | |
| |||
659 | 664 | | |
660 | 665 | | |
661 | 666 | | |
662 | | - | |
| 667 | + | |
663 | 668 | | |
664 | 669 | | |
665 | 670 | | |
| |||
0 commit comments