Automattic / Automattic/jetpack
stats_get_csv(): Post view data for 1 day is empty between midnight UTC and midnight local time
- Dominant language
- PHP
- Stars
- 1.8k
- Forks
- 898
- Avg merge
- 1d 18h
- Merged PRs (30d)
- 774
Description
For sites in a UTC minus timezone, `stats_get_csv()` can unexpectedly return an empty array.
#### Steps to reproduce the issue
1. Choose a site which has the `gmt_offset` option set to a negative value, and which receives traffic
2. Between midnight UTC and midnight in the site's local time, run `stats_get_csv('postviews', array('days' => 1));`, observe an empty array
3. Run `stats_get_csv('postviews', array('days' => 2));`, observe a non-empty array.
4. After midnight in the site's local time, run `stats_get_csv('postviews', array('days' => 1));`, observe a non-empty array.
#### What I expected
The function should return post view stats for the previous day (or 24 hour period) in the site's local time. It should only return empty if there have been zero post views over that period.
---
Related tickets
#110040-zd-wordpressvip
#114127-zd-wordpressvip
Contributor guide
Research direction
Start at the stats_get_csv('postviews') entry point and reproduce the one-day and two-day calls during the UTC/local-midnight interval described in the issue. Trace how the site's negative gmt_offset affects the selected period and compare the returned arrays. Done means a one-day request returns the previous local day or 24-hour period's post views, while remaining empty when that period has no views.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- analytics, api
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100