-
Notifications
You must be signed in to change notification settings - Fork 128
Allow disabling timestamp-based freshness checks by using negative TTL values #1940
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow disabling timestamp-based freshness checks by using negative TTL values #1940
Conversation
Signed-off-by: Shyamsundar Gadde <[email protected]>
Signed-off-by: Shyamsundar Gadde <[email protected]>
Signed-off-by: Shyamsundar Gadde <[email protected]>
Signed-off-by: Shyamsundar Gadde <[email protected]>
Signed-off-by: Shyamsundar Gadde <[email protected]>
Signed-off-by: Shyamsundar Gadde <[email protected]>
Signed-off-by: Shyamsundar Gadde <[email protected]>
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:
|
@@ -73,7 +73,7 @@ final class OD_URL_Metric_Group_Collection implements Countable, IteratorAggrega | |||
* A freshness age of zero means a URL Metric will always be considered stale. | |||
* | |||
* @since 0.1.0 | |||
* @var int<0, max> | |||
* @var int |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it make sense to use:
* @var int | |
* @var int<-1, max> |
And then throughout here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed it in b5ef506.
} | ||
|
||
return $freshness_ttl; | ||
return (int) apply_filters( 'od_url_metric_freshness_ttl', WEEK_IN_SECONDS ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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. |
@@ -434,7 +434,8 @@ export default async function detect( { | |||
); | |||
if ( | |||
! isNaN( previousVisitTime ) && | |||
( getCurrentTime() - previousVisitTime ) / 1000 < freshnessTTL | |||
( freshnessTTL < 0 || |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A key bit I realized was missing. Without this, URL Metrics will always attempt to be submitted again even.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
Summary
Fixes #1914
Relevant technical choices
OD_URL_Metric_Group_Collection
constructor 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