la_mojo: close day report at local midnight and open the next day's #9
Merged
ClaudeAI
merged 1 commits from fix/report-day-rollover into master 2 hours ago
Loading…
Reference in new issue
There is no content yet.
Delete Branch 'fix/report-day-rollover'
Deleting a branch is permanent. It CANNOT be undone. Continue?
Summary
At local midnight, the open day report (
data/reports/YYYY/MM/DD/report.db, plus the pictures and videos stored next to it) is now closed, and the next day's report directory is opened.Root cause
The only code that moved the report to a new day sat in the
SESSION_STARTbranch ofsqliteDBC::updateStats(), and that branch never ran:updateStats()starts withif (m_bStaIsConnected && (evt || video)), but session status changes are reported asupdateStats(false, false, SESSION_xxx). So the report only changed day when the process restarted, and everything after midnight went into the previous day's report.Changes
mojoKernel::handleDayChange()(called every second fromvalidateReports()), at local midnight:DAY_CHANGE_MAX_VIDEO_WAIT(90 s), so the video is stored next to its events.sqliteDBC::switchReportToCurrentDay()/openDayReport(): opens or creates the current local day's directory and database, and retries if that fails. The 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(): session status changes are no longer filtered out, so the session counters instat.db(days.session_count/session_closed) are now actually updated, andSESSION_STARTalso switches the report when needed.Testing
Test programs built around the real
sqliteDBCcode, run underfaketimestarting at 23:59:57-58 in Asia/Jerusalem:stat.dbshows 26th: 1 session, closed; 27th: 1 session, open.Debug86flags with no new warnings. The full program wasn't run.Generated with Claude Code
https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
495e21b49b.