Apologies if I am misunderstanding how your code works, but I don’t see how the cache can be used when the wp-admin/admin.php?page=ppc-stats link in the navigation is used.
The cache system looks for an exact match on the start/end times:
//If there are full-cache stats available, use them. These can be generated only through WP-CLI
if( ! is_array( $author ) AND ! $perm->can_see_others_general_stats() )
$cache_slug = 'ppc_stats-tstart_'.$time_start.'-tend_'.$time_end.'-author_'.$current_user->ID.'-as-user'.$current_user->ID;
else if( is_array( $author ) )
$cache_slug = 'ppc_stats-tstart_'.$time_start.'-tend_'.$time_end.'-author_'.$author[0].'-as-user_'.$author[0];
else
$cache_slug = 'ppc_stats-tstart_'.$time_start.'-tend_'.$time_end.'-as-user_'.$current_user->ID;<code></code>
If stats_tend is not set in the URL then they default to the first_available_post_time and last_available_post_time, for example:
<code></code>ppc_stats-tstart_1614125607-tend_1657257966-as-user_1<code></code>
But the CLI command appears to generate a different tend value each time:
wp ppc stats --time-start=2022-07-01 --cache-full
Now loading stats...
Time range: 2022-07-01 - 2022-07-08
As user: example (ID: 1)
This may take a while...
Cached stats with slug ppc_stats-tstart_1656633600-tend_1657258938-as-user_1, size 7769 KB, outcome 1
Success: Stats generated in 1 seconds.
Visit them at: https://example.co/wp-admin/admin.php?page=ppc-stats&tstart=1656633600&tend=1657258938&cache-full&author=
baseos | sgvps.net:~/www/example.co/public_html$ wp ppc stats --time-start=2022-07-01 --cache-full
Now loading stats...
Time range: 2022-07-01 - 2022-07-08
As user: example (ID: 1)
This may take a while...
Cached stats with slug ppc_stats-tstart_1656633600-tend_1657258946-as-user_1, size 7769 KB, outcome 1
Success: Stats generated in 0 seconds.
Visit them at: https://example.co/wp-admin/admin.php?page=ppc-stats&tstart=1656633600&tend=1657258946&cache-full&author=
baseos | sgvps.net:~/www/example.co/public_html$
The tstart value does appear to be correct (match first_available_post) when no parameters are set:
$ wp ppc stats --cache-full
Now loading stats...
Time range: 2021-02-24 - 2022-07-08
As user: example (ID: 1)
This may take a while...
Cached stats with slug ppc_stats-tstart_1614125607-tend_1657258495-as-user_1, size 426801 KB, outcome 1
Success: Stats generated in 156 seconds.
Visit them at: https://example.co/wp-admin/admin.php?page=ppc-stats&tstart=1614125607&tend=1657258495&cache-full&author=
For reference, here is the PPC global settings:
["first_available_post_time"]=>
int(1614125607)
["last_available_post_time"]=>
int(1657257966)
["stats_tstart"]=>
string(10) "1614125607"
["stats_tend"]=>
string(10) "1657257966"
-
This reply was modified 2 years, 8 months ago by
DannyCooper.
-
This reply was modified 2 years, 8 months ago by
DannyCooper.
-
This reply was modified 2 years, 8 months ago by
DannyCooper.