Description
On AI Request Logs (/wp-admin/admin.php?page=ai-request-logs or equivalent), the header time-period dropdown correctly filters the log table for short windows, but the summary cards at the top (total requests, tokens, duration, success rate) show 0 when “Last Hour” (or “Last Minute”) is selected—even when requests were made within the last hour.
Switching back to “Last 24 Hours” restores the expected non-zero counters for the same recent requests.
Expected behavior
Summary statistics for “Last Hour” include all logs whose timestamps fall within the last hour (same as the table filter for that period).
Actual behavior
Summary statistics are zero for short periods on sites where the MySQL/server timezone is not UTC, while longer periods (e.g. 24 hours) still show data.
Root cause
Log rows store timestamp in GMT via current_time( 'mysql', true ) in AI_Request_Log_Repository::insert(), but get_date_condition() used MySQL NOW() (server-local time) for summary queries. For short intervals, that mismatch can exclude recent GMT timestamps from the summary WHERE clause. The logs list is less affected because the UI sends date_from in UTC from periodToDateFrom() in src/admin/ai-request-logs/index.tsx.
Affected code
includes/Logging/AI_Request_Log_Repository.php — get_date_condition() (summary path via get_summary()).
Suggested fix
Use UTC_TIMESTAMP() instead of NOW() in get_date_condition() so period filters align with GMT-stored timestamps.
Step-by-step reproduction instructions
- Use a WordPress install where the server/MySQL timezone is not UTC (e.g. US/New York, Europe/Berlin) - this makes the bug easiest to see.
- Ensure the AI plugin is active and AI request logging is enabled.
- Trigger at least one AI request (e.g. use an AI feature in the plugin) and confirm a new row appears in AI Request Logs within the last hour.
- Open AI Request Logs in wp-admin.
- Confirm summary cards show non-zero values with the default “Last 24 Hours” period.
- Change the header dropdown to “Last Hour”.
- Observe the summary cards drop to 0 (or otherwise incorrect totals).
- Confirm the log table may still list recent entries (depending on filters), or switch period and note the inconsistency between cards and table.
- Switch back to “Last 24 Hours” and observe summary cards show the correct counts again.
Screenshots, screen recording, code snippet
Environment info
No response
Please confirm that you have searched existing issues in the repo.
Please confirm that you have tested with all plugins deactivated except the AI plugin.
Please confirm which theme type you used for testing.
Description
On AI Request Logs (/wp-admin/admin.php?page=ai-request-logs or equivalent), the header time-period dropdown correctly filters the log table for short windows, but the summary cards at the top (total requests, tokens, duration, success rate) show 0 when “Last Hour” (or “Last Minute”) is selected—even when requests were made within the last hour.
Switching back to “Last 24 Hours” restores the expected non-zero counters for the same recent requests.
Expected behavior
Summary statistics for “Last Hour” include all logs whose timestamps fall within the last hour (same as the table filter for that period).
Actual behavior
Summary statistics are zero for short periods on sites where the MySQL/server timezone is not UTC, while longer periods (e.g. 24 hours) still show data.
Root cause
Log rows store timestamp in GMT via current_time( 'mysql', true ) in AI_Request_Log_Repository::insert(), but get_date_condition() used MySQL NOW() (server-local time) for summary queries. For short intervals, that mismatch can exclude recent GMT timestamps from the summary WHERE clause. The logs list is less affected because the UI sends date_from in UTC from periodToDateFrom() in src/admin/ai-request-logs/index.tsx.
Affected code
includes/Logging/AI_Request_Log_Repository.php — get_date_condition() (summary path via get_summary()).
Suggested fix
Use UTC_TIMESTAMP() instead of NOW() in get_date_condition() so period filters align with GMT-stored timestamps.
Step-by-step reproduction instructions
Screenshots, screen recording, code snippet
Environment info
No response
Please confirm that you have searched existing issues in the repo.
Please confirm that you have tested with all plugins deactivated except the AI plugin.
Please confirm which theme type you used for testing.