la_mojo: one report database per hour (report_HH.db) #10
Merged
ClaudeAI
merged 1 commits from feature/hourly-report-db into master 2 hours ago
Loading…
Reference in new issue
There is no content yet.
Delete Branch 'feature/hourly-report-db'
Deleting a branch is permanent. It CANNOT be undone. Continue?
Summary
The report engine now keeps a separate report database for every local hour inside the day folder:
The name comes from
REPORT_DB_NAME_FMT("report_%02d.db") inSQLite_dataBinder.h. Pictures and videos stay in the day folder, and the day statistics instat.dbare unchanged.Sessions at the hour change
The same rule as at midnight, applied every hour:
REPORT_SWITCH_MAX_VIDEO_WAIT(90 s).So every hourly file contains complete sessions, and a long alarm appears as consecutive sessions.
Code
sqliteDBC::openHourReport()replacesopenDayReport().switchReportToCurrentHour()(renamed fromswitchReportToCurrentDay()) switches when the local day or hour changes.connect()opens the current hour's file at startup.mojoKernel::handleReportPeriodChange()(washandleDayChange()) runs the close-then-switch sequence on every local hour change.getLocalHour()helper added inbasicFunctionality.Action needed outside this repository
The web UI that displays reports (under
/srv/www/...) is not in this repository. It must be updated to read allreport_HH.dbfiles in a day folder instead ofreport.db. Existing day folders keep their oldreport.db(no migration).Testing
Test program built around the real
sqliteDBCcode, run underfaketime(Asia/Jerusalem), with a second thread writing an event every 2 ms and ThreadSanitizer enabled:report_13.dbandreport_14.dbin the same day folder. The session's START and END are inreport_13.db, and the new session's START is inreport_14.db. All 723 events stored.26/report_23.dband27/report_00.db, same session behavior. All 705 events stored.Debug86flags with no new warnings. The full program was not run.Generated with Claude Code
https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
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_0139veDo3XyavMuVhdnHcN16The web UI side is in gagua/Mojo_Web: Reports: read hourly report_HH.db files (feature/hourly-report-db). Merge and deploy both together.
70a333ab67.