Reports: read hourly report_HH.db files #1

Merged
ClaudeAI merged 2 commits from feature/hourly-report-db into master 2 hours ago
ClaudeAI commented 2 hours ago
Collaborator

Summary

The web UI now reads the hourly report databases that la_mojo writes from gagua/dr_frucht pull request #10: one report_HH.db per local hour in each day folder (data/reports/YYYY/MM/DD/). Days recorded earlier keep their single report.db and 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 AUTOINCREMENT per 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:

id = slot * 10000000 + rowid      slot 0..23 = hour file, 24 = legacy report.db

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, because SQLite_DB opens with the create flag, so it checks that the file exists first. Loaded from ajax_asm.php and added to files.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: the BID..EID range 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. A LSID from 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) and report_11.db (open session). The day tree came from getHistoryDay, 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 up report_12.db as soon as it appears.
  • No side effects: no stray report files were created.

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.timezone in php.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/localtime as maintained by timedatectl, then /etc/timezone, then TZ. It's loaded right after settings.php by ajax_asm, assembler, js_asm, soap_asm and ui_asm, and added to files.list.
  • Calendar day key: getHistoryDates now returns the host-local noon of each day, and getHistoryDay uses 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.
  • Video download file name: now uses the host-local time from getVideoInfo instead of the browser's time zone.

Tested by switching the test host's /etc/localtime to 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.

## Summary The web UI now reads the hourly report databases that la_mojo writes from gagua/dr_frucht pull request #10: one `report_HH.db` per local hour in each day folder (`data/reports/YYYY/MM/DD/`). Days recorded earlier keep their single `report.db` and 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 `AUTOINCREMENT` per 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: ``` id = slot * 10000000 + rowid slot 0..23 = hour file, 24 = legacy report.db ``` 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, because `SQLite_DB` opens with the create flag, so it checks that the file exists first. Loaded from `ajax_asm.php` and added to `files.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`:** the `BID..EID` range 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. A `LSID` from 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) and `report_11.db` (open session). The day tree came from `getHistoryDay`, 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 up `report_12.db` as soon as it appears. - **No side effects:** no stray report files were created. Not tested in a browser. Generated with [Claude Code](https://claude.com/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.timezone` in `php.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/localtime` as maintained by `timedatectl`, then `/etc/timezone`, then `TZ`. It's loaded right after `settings.php` by `ajax_asm`, `assembler`, `js_asm`, `soap_asm` and `ui_asm`, and added to `files.list`. - **Calendar day key:** `getHistoryDates` now returns the host-local noon of each day, and `getHistoryDay` uses 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. - **Video download file name:** now uses the host-local time from `getVideoInfo` instead of the browser's time zone. **Tested** by switching the test host's `/etc/localtime` to 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.
ClaudeAI added 1 commit 2 hours ago
16534fd591
Reports: read hourly report_HH.db files
ClaudeAI added 1 commit 2 hours ago
036be22fa4
Reports: show times in the host's local time zone
ClaudeAI merged commit 7450b0fce1 into master 2 hours ago
The pull request has been merged as 7450b0fce1.
Sign in to join this conversation.
No reviewers
No Label
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date

No due date set.

Dependencies

This pull request currently doesn't have any dependencies.

Loading…
There is no content yet.