| @@ -1,8 +1,8 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | 3 | * @package FireBox |
| 4 | - * @version 3.1.8 Free | |
| 4 | + * @version 3.1.14 Free | |
| 5 | 5 | * |
| 6 | 6 | * @author FirePlugins <[email protected]> |
| 7 | 7 | * @link https://www.fireplugins.com |
| 8 | 8 | * @copyright Copyright © 2026 FirePlugins All Rights Reserved |
| @@ -34,6 +34,30 @@ | ||
| 34 | 34 | $newEndDate->add(new \DateInterval("P{$period}D")); |
| 35 | 35 | $newEndDateStr = $newEndDate->format('Y/m/d 23:59:59'); |
| 36 | 36 | |
| 37 | 37 | return [$newStartDateStr, $newEndDateStr]; |
| 38 | + } | |
| 39 | + | |
| 40 | + /** | |
| 41 | + * Determine the transient TTL to use for cached analytics data. | |
| 42 | + * Only fully-past date ranges are cached. Ranges that include today are | |
| 43 | + * still being collected, and caching them makes freshly tracked views and | |
| 44 | + * conversions appear to be missing from the dashboard. | |
| 45 | + * | |
| 46 | + * @param string $end_date The end date of the range (e.g. 'Y/m/d H:i:s'). | |
| 47 | + * | |
| 48 | + * @return int TTL in seconds, or 0 when the range must not be cached. | |
| 49 | + */ | |
| 50 | + protected function getAnalyticsCacheTtl($end_date) | |
| 51 | + { | |
| 52 | + $end_date_ts = strtotime($end_date); | |
| 53 | + | |
| 54 | + if ($end_date_ts && $end_date_ts < strtotime('today midnight', current_time('timestamp'))) | |
| 55 | + { | |
| 56 | + // Fully-past range: data is no longer being collected for it. | |
| 57 | + return HOUR_IN_SECONDS; | |
| 58 | + } | |
| 59 | + | |
| 60 | + // Range includes today: always serve live data. | |
| 61 | + return 0; | |
| 38 | 62 | } |
| 39 | 63 | } |