Reports: read hourly report_HH.db files #1
Merged
ClaudeAI
merged 2 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 web UI now reads the hourly report databases that la_mojo writes from gagua/dr_frucht pull request #10: one
report_HH.dbper local hour in each day folder (data/reports/YYYY/MM/DD/). Days recorded earlier keep their singlereport.dband still display. A day during the upgrade has both kinds of file.Deploy together with gagua/dr_frucht pull request #10.
Global report ids
Event, picture and video ids are
AUTOINCREMENTper database file, so the same id repeats across the hourly files of a day. Ids sent to the browser therefore carry the file they belong to:The largest id is 249,999,999, which fits a 32-bit integer. The JavaScript only passes ids back to the server and never computes with them, so no JavaScript changes are needed (including in
jsapi_dynamic).Changes
lib/php/db/report_files.php(new): lists a day's report files and encodes/decodes ids. It never creates a report file, becauseSQLite_DBopens with the create flag, so it checks that the file exists first. Loaded fromajax_asm.phpand added tofiles.list.getHistoryDay: sessions and "Events by Hours" come from all files of the day. The legacy file is split by hour as before; each hourly file is one node. A session still open runs to the end of its file.getHistoryEvents,getBubbleAnalysis,setPermanentBubbles: theBID..EIDrange is resolved to its file.getVideoInfo,getPictureInfo,getFrames: event and video ids are resolved to their file, and video ids are returned as global ids.getStatus(live log): reads the newest hourly file of the newest day. ALSIDfrom a previous hour or day starts again at the beginning of the new file.Testing
Ran the real controllers with PHP 8.3 against a test day containing a legacy
report.db(09:00),report_10.db(session with a video and a picture) andreport_11.db(open session). The day tree came fromgetHistoryDay, and its ids were passed to the other controllers as the browser does:getHistoryDay: sessions 09:10 / 10:05 / 11:20 (open), hours 09:00 / 10:00 / 11:00.getHistoryEvents: the correct events for each session; the video/picture flags are set on the right events.getVideoInfo→getFrames: returns the video and streams its frames.getPictureInfo: returns the picture.getBubbleAnalysis: works on the 10:05 range.getStatus: returns new events, does not repeat events already shown, and picks upreport_12.dbas soon as it appears.Not tested in a browser.
Generated with Claude Code
https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
Second commit: show times in the host's local time zone
PHP ignores the host's time zone. Without
date.timezoneinphp.ini, which the installer doesn't set, it uses UTC. So session labels, event times, the hour nodes and the live log were shown in UTC, while la_mojo names report folders and files in local time.lib/php/host_timezone.php(new): sets PHP's time zone from the host, using/etc/localtimeas maintained bytimedatectl, then/etc/timezone, thenTZ. It's loaded right aftersettings.phpbyajax_asm,assembler,js_asm,soap_asmandui_asm, and added tofiles.list.getHistoryDatesnow returns the host-local noon of each day, andgetHistoryDayuses it directly. The old key, "local midnight + current UTC offset" applied twice, only worked for hosts east of UTC and could be off by a day across a daylight-saving change.getVideoInfoinstead of the browser's time zone.Tested by switching the test host's
/etc/localtimeto Asia/Jerusalem, America/New_York, Pacific/Auckland and UTC. For each zone, a winter date and a daylight-saving summer date had sessions at 00:30 and 23:30 local time. In every case the calendar cell (browser in the same zone), the opened day folder, the session labels and every event time matched the host's local time.la_mojo now writes one report database per local hour into the day folder (data/reports/YYYY/MM/DD/report_HH.db) instead of a single report.db. Days recorded earlier keep their report.db; a day during the upgrade has both. - lib/php/db/report_files.php (loaded by ajax_asm.php, added to files.list): lists a day's report files and maps ids. Row ids are per file, so ids sent to the browser are global: id = slot * 10000000 + rowid (slot 0..23 = hour, 24 = legacy report.db) The JavaScript treats ids as opaque, so no JavaScript changes are needed. Report files are never created by the web UI (existence is checked). - getHistoryDay: sessions and "Events by Hours" from all files of the day (legacy file split by hour as before, one node per hourly file). - getHistoryEvents, getBubbleAnalysis, setPermanentBubbles: BID..EID range resolved to its file. - getVideoInfo, getPictureInfo, getFrames: event/video ids resolved to their file; video ids returned as global ids. - getStatus (live log): newest hourly file of the newest day; LSID from a previous hour/day restarts at the beginning of the new file. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN167450b0fce1.