You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
AI Request Logs: "Last 30 Days" summary uses a calendar month, not 30 days, so cards and table disagree #752
On the AI Request Logs screen, the header time-period dropdown offers "Last 30 Days" (period=month). When this option is selected, the summary cards at the top and the logs table below are filtered with two different window definitions, so their counts can disagree for the same selection.
The summary cards call the REST summary endpoint, which builds the cutoff server-side with a calendar month: DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 MONTH). A calendar month spans 28–31 days depending on the current date.
The logs table sends a date_from computed in the browser as a fixed 30 days (30 * 24 * 60 * 60 * 1000 ms).
Because both are driven by the same dropdown selection — labelled "Last 30 Days" — they should cover the same window. They don't: in a month whose look-back is 31 days, the summary cards count an extra day of logs that the table excludes; in a February look-back (28 days), the summary cards count fewer.
I expect the summary cards and the logs table to cover the same 30-day window that the "Last 30 Days" label promises. Instead they use different windows and can show mismatched totals.
The other periods (Last Minute / Hour / 24 Hours / 7 Days) use matching fixed offsets on both sides and are unaffected — only month diverges.
Step-by-step reproduction instructions
Enable AI request logging and accumulate logs spanning the last ~31 days (or insert rows with timestamps 29 and 31 days old).
Open AI Request Logs.
In the header dropdown, select "Last 30 Days".
Compare the Total Requests value on the summary card with the number of rows in the table (X-WP-Total).
In a month preceded by a 31-day month, the summary card counts logs from the last 31 days while the table only counts the last 30 — the two totals differ.
Code snippet
The two divergent definitions, both fed by the same period=month selection:
// includes/Logging/AI_Request_Log_Repository.php — get_date_condition()
case 'month':
return'AND timestamp >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 MONTH)'; // 28–31 days
// src/admin/ai-request-logs/index.tsx — PERIOD_OFFSETS_MSmonth: 30*24*60*60*1000,// exactly 30 days
Activity