mirror of
https://github.com/ZoneMinder/zoneminder.git
synced 2026-10-03 16:05:24 -04:00
DateTime is a pseudo-attribute meaning "the event was running then", so a window over it should select events that overlap the window. The code applied the term's own operator to both StartDateTime and EndDateTime, which turns the upper bound into StartDateTime <= max AND EndDateTime <= max -- a containment test. Any event spanning the end of the window was dropped, which under continuous recording is most of them, and with events longer than the window, all of them. Montage review showed an empty timeline as a result. The lower bound now tests the event's end and the upper bound its start. The EndDateTime IS NULL allowance is also bounded. It was there so an event still being written stays visible, but as written it made every crash-orphaned event ever recorded match every window: montage review was returning events from two weeks earlier and nothing from the requested hour. An event with no EndDateTime still has Length, flushed every few seconds by zmc, so StartDateTime + Length is its effective end; only an event with neither falls back to NOW(). This is the same expression the Event model already uses for its EndTimeSecs virtual field. Verified against a live instance: for a 09:43-10:43 window that had one overlapping event per monitor, the API returned 8 events for monitor 1, all crash orphans from 2026-07-26 and none from the window. It now returns the overlapping event, and montage review draws it and renders its frames.