Allow disabling timestamp-based freshness checks by using negative TTL values#1940
Conversation
Signed-off-by: Shyamsundar Gadde <shyamsundar.gadde@rtcamp.com>
Signed-off-by: Shyamsundar Gadde <shyamsundar.gadde@rtcamp.com>
Signed-off-by: Shyamsundar Gadde <shyamsundar.gadde@rtcamp.com>
Signed-off-by: Shyamsundar Gadde <shyamsundar.gadde@rtcamp.com>
Signed-off-by: Shyamsundar Gadde <shyamsundar.gadde@rtcamp.com>
Signed-off-by: Shyamsundar Gadde <shyamsundar.gadde@rtcamp.com>
Signed-off-by: Shyamsundar Gadde <shyamsundar.gadde@rtcamp.com>
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## trunk #1940 +/- ##
=======================================
Coverage 71.08% 71.09%
=======================================
Files 86 86
Lines 6969 6970 +1
=======================================
+ Hits 4954 4955 +1
Misses 2015 2015
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| * | ||
| * @since 0.1.0 | ||
| * @var int<0, max> | ||
| * @var int |
There was a problem hiding this comment.
Would it make sense to use:
| * @var int | |
| * @var int<-1, max> |
And then throughout here.
| } | ||
|
|
||
| return $freshness_ttl; | ||
| return (int) apply_filters( 'od_url_metric_freshness_ttl', WEEK_IN_SECONDS ); |
There was a problem hiding this comment.
Per above, this could be:
| return (int) apply_filters( 'od_url_metric_freshness_ttl', WEEK_IN_SECONDS ); | |
| $ttl = (int) apply_filters( 'od_url_metric_freshness_ttl', WEEK_IN_SECONDS ); | |
| return max( -1, $ttl ); |
|
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 If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
| if ( | ||
| ! isNaN( previousVisitTime ) && | ||
| ( getCurrentTime() - previousVisitTime ) / 1000 < freshnessTTL | ||
| ( freshnessTTL < 0 || |
There was a problem hiding this comment.
A key bit I realized was missing. Without this, URL Metrics will always attempt to be submitted again even.
Summary
Fixes #1914
Relevant technical choices
OD_URL_Metric_Group_Collectionconstructor to accept negative freshness TTL valuesOD_URL_Metric_Group::is_complete()to skip timestamp checks when freshness TTL is negativeod_get_url_metric_freshness_ttl()function to allow negative values