-
Notifications
You must be signed in to change notification settings - Fork 128
Change default garbage collection TTL of od_url_metrics
posts from 1 month to 3 months and add the filter to customize expiration
#1950
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
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## trunk #1950 +/- ##
==========================================
+ Coverage 72.26% 72.27% +0.01%
==========================================
Files 85 85
Lines 6958 6961 +3
==========================================
+ Hits 5028 5031 +3
Misses 1930 1930
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:
|
plugins/optimization-detective/storage/class-od-url-metrics-post-type.php
Outdated
Show resolved
Hide resolved
plugins/optimization-detective/storage/class-od-url-metrics-post-type.php
Outdated
Show resolved
Hide resolved
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. |
Hi @westonruter, This is now ready for the review. Updates: Have updated the filter to only use the number, and also added the test case for the filter usage. Let me know if that filter usage test case should be in another function or any improvements in that. Thank You, |
plugins/optimization-detective/storage/class-od-url-metrics-post-type.php
Outdated
Show resolved
Hide resolved
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.
Just some tweaks.
plugins/optimization-detective/storage/class-od-url-metrics-post-type.php
Outdated
Show resolved
Hide resolved
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.
Thanks!
od_url_metrics
posts from 1 month to 3 months and add the filter to customize TTL
od_url_metrics
posts from 1 month to 3 months and add the filter to customize TTLod_url_metrics
posts from 1 month to 3 months and add the filter to customize expiration
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 couple more copy tweaks
); | ||
|
||
// Update timestamp to 6 months older. | ||
$new_stale_timestamp_gmt = gmdate( 'Y-m-d H:i:s', time() - ( 6 * MONTH_IN_SECONDS * HOUR_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.
Oh, why is this multiplying MONTH_IN_SECONDS * HOUR_IN_SECONDS
? Shouldn't this rather be rather one second longer than the expiration age of 6 * MONTH_IN_SECONDS
?:
$new_stale_timestamp_gmt = gmdate( 'Y-m-d H:i:s', time() - ( 6 * MONTH_IN_SECONDS * HOUR_IN_SECONDS ) ); | |
$new_stale_timestamp_gmt = gmdate( 'Y-m-d H:i:s', time() - ( 6 * MONTH_IN_SECONDS + 1 ) ); |
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.
Shouldn't this rather be rather one second longer than the expiration age of 6 * MONTH_IN_SECONDS
Yes it could be, but I thought to carry the same from the above where HOURS_IN_SECONDS was used.
I would change to + 1
rather. but not sure if it could make much difference IMO?
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.
I'm not sure I understand. What is MONTH_IN_SECONDS * HOUR_IN_SECONDS
supposed to mean? That's like saying 3600 months of seconds. Multiplying seconds by other seconds doesn't make sense to me.
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.
This makes sense, but I added because it was previously added here in the test -
performance/plugins/optimization-detective/tests/storage/test-class-od-url-metrics-post-type.php
Line 291 in 48db4ba
$stale_timestamp_gmt = gmdate( 'Y-m-d H:i:s', strtotime( '-1 month' ) - HOUR_IN_SECONDS ); |
So to make more consistent I have added that.
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.
Ah, but that is quite different. That's subtracting one unit of seconds from another unit of seconds, so the resulting unit is seconds. By multiplying two units of seconds together then you kinda get a strange unit: 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.
Ah, but that is quite different. That's subtracting one unit of seconds from another unit of seconds, so the resulting unit is seconds. By multiplying two units of seconds together then you kinda get a strange unit: seconds².
Yep Gotcha!
Summary
Fixes #1948
Relevant technical choices
od_url_metric_garbage_collection_ttl
which filters the ttl time for gargage collection for url_metrics of the post and defaults to 3 months in seconds.