The report engine now keeps a separate SQLite database for every local
hour inside the day folder:
data/reports/YYYY/MM/DD/report_HH.db (REPORT_DB_NAME_FMT "report_%02d.db")
Pictures and videos stay in the day folder; the stat.db day records are
unchanged.
- sqliteDBC::openHourReport(): opens/creates report_HH.db of the given day
and hour (replaces openDayReport); switchReportToCurrentHour() (renamed
from switchReportToCurrentDay) switches when the local day or hour
changes. connect() opens the current hour's file at startup.
- mojoKernel::handleReportPeriodChange() (was handleDayChange): runs the
same close-then-switch sequence every local hour: an open session that
started in the previous hour is closed in the old file (waiting at most
REPORT_SWITCH_MAX_VIDEO_WAIT for a recording with events), then the
report switches to the new hour; the next event opens a new session.
Each hourly file therefore contains complete sessions.
- getLocalHour() helper in basicFunctionality.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
Before, the report (data/reports/YYYY/MM/DD/report.db, plus pictures and
videos stored next to it) only moved to a new day inside
updateStats(SESSION_START) - and that branch never ran, because
updateStats() skipped every call with evt=false/video=false, which is how
all session status changes are reported. So the report only changed day
when the process restarted; everything after midnight went into the
previous day's report.
- mojoKernel::handleDayChange() (every second from validateReports):
at local midnight an open session that started on the previous day is
closed (END event goes into the old report). If a video segment with
events is still recording, wait for it at most DAY_CHANGE_MAX_VIDEO_WAIT
(90 s) so the video is stored next to its events. After the END event is
written, the report is switched to the new day. The next event starts a
new session in the new day's report.
- sqliteDBC::switchReportToCurrentDay() / openDayReport(): opens (creates)
the current local day's report directory and database, retried until it
succeeds. Report state is protected by a recursive mutex because the
switch runs on the kernel thread while events are written on the event
thread.
- updateStats(): no longer drops SESSION_START/END/DROP calls, so the
session counters in stat.db are updated and SESSION_START also switches
the report if needed.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16