Skip to content

Fix: Summary counters show zero for “Last Hour” when requests are recent in AI Request Logs#671

Merged
dkotter merged 3 commits into
WordPress:developfrom
prasadkarmalkar:fix/logs-summary-utc-timestamp
Jun 5, 2026
Merged

Fix: Summary counters show zero for “Last Hour” when requests are recent in AI Request Logs#671
dkotter merged 3 commits into
WordPress:developfrom
prasadkarmalkar:fix/logs-summary-utc-timestamp

Conversation

@prasadkarmalkar
Copy link
Copy Markdown
Contributor

@prasadkarmalkar prasadkarmalkar commented Jun 5, 2026

What?

Closes #666

Why?

On AI Request Logs, the header time-period dropdown correctly filters the log table for short windows. Still, the summary cards at the top show 0 when “Last Hour” is selected, even when requests were made within the last hour.

How?

Replace NOW() with UTC_TIMESTAMP() in all get_date_condition() cases so the period cutoff aligns with the stored GMT timestamps.

Testing Instructions

  1. 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.
  2. Ensure the AI plugin is active, and AI request logging is enabled.
  3. 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.
  4. Open AI Request Logs in wp-admin.
  5. Change the header dropdown to “Last Hour”.
  6. Check the summary cards' values are non-zero

Screenshots or screencast

Before After
Screenshot 2026-06-05 at 11 09 17 AM Screenshot 2026-06-05 at 12 35 36 PM

Changelog Entry

Fixed - Summary statistics showing zero for short time periods on non-UTC MySQL servers.

Open WordPress Playground Preview

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 5, 2026

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

Unlinked Accounts

The following contributors have not linked their GitHub and WordPress.org accounts: @alexWinterjuice.

Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Unlinked contributors: alexWinterjuice.

Co-authored-by: prasadkarmalkar <prasadkarmalkar@git.wordpress.org>
Co-authored-by: dkotter <dkotter@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@codecov
Copy link
Copy Markdown

codecov Bot commented Jun 5, 2026

Codecov Report

❌ Patch coverage is 50.00000% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 74.68%. Comparing base (4f27b52) to head (75717dd).
⚠️ Report is 6 commits behind head on develop.

Files with missing lines Patch % Lines
includes/Logging/AI_Request_Log_Repository.php 50.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             develop     #671   +/-   ##
==========================================
  Coverage      74.68%   74.68%           
  Complexity      1754     1754           
==========================================
  Files             85       85           
  Lines           7549     7549           
==========================================
  Hits            5638     5638           
  Misses          1911     1911           
Flag Coverage Δ
unit 74.68% <50.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@dkotter dkotter added this to the 1.1.0 milestone Jun 5, 2026
@dkotter dkotter merged commit c71c9c9 into WordPress:develop Jun 5, 2026
22 of 24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AI Request Logs: summary counters show zero for “Last Hour” when requests are recent

2 participants