-
Notifications
You must be signed in to change notification settings - Fork 110
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
Fix triggering post update actions after storing a URL Metric and refactor REST API endpoint logic into class #1865
Conversation
…base This commit adds new class `class-od-rest-api.php` from `rest-api.php` file and adds the necessary required changes whereever normal functions were used, that are now refrencing the class static methods and variables. Also updated the test file test-rest-api.php to test-class-od-rest-api.php file and updated the required test cases as per the class. Note: Have directly used function docs and comment that were present in the original file.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## trunk #1865 +/- ##
==========================================
+ Coverage 71.18% 71.25% +0.06%
==========================================
Files 85 85
Lines 7000 7006 +6
==========================================
+ Hits 4983 4992 +9
+ Misses 2017 2014 -3
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:
|
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. |
… for optimization detective This commit adds the deprecated.php file which has the global constant that are being inside image priortizer and updated the OD plugin to use this constants via a dedicated methods.
Hi @westonruter, I have updated the PR with the required change, I need some inputs on,
Can you please suggest what should be there in both the cases? Thank You, |
That is correct.
Here's one way: bd3f309. |
… prefix from methods
Hi @westonruter, adding this for visibility, I would be going for long vacation starting tomorrow, so if we can land this PR before that, it would be very helpful, else I would not able to work on feedbacks after tomorrow 🙇. Apologies! |
@hbhalodia got it! Unfortunately we may not be able to finish this before you go on vacation since my availability is limited now for the next week and a half per #1850 (comment). |
Hey @westonruter, No issues. I will cover once back. Also, let's meet at WC Asia 🙌, I would be also there. |
@hbhalodia Did we end up crossing paths at WC Asia? I'm sorry to say I can't recall chatting with you, although there were so many people my memory may have been overloaded. I've resolved the merge conflicts introduced by #1867 by porting the change to |
Hi @westonruter, unfortunately not. Thanks for resolving the conflicts. Also is there anything pending in this PR other than, #1865 (comment)? Let me know as I am back from vacation and would work on the same. Thank You, |
@hbhalodia ah, sorry we couldn't connect in Manila. For this PR, the bigger aspect to get clarity on is #1859 (comment). Based on @felixarntz's feedback there we may not use a static class but rather a singleton class. You can expect a resolution to that discussion tomorrow. |
Ah, alright, I missed that. No worries, we can update the PR based on the discussion and resolution. Thank You, |
plugins/optimization-detective/storage/class-od-rest-url-metrics-store-endpoint.php
Outdated
Show resolved
Hide resolved
plugins/optimization-detective/storage/class-od-rest-url-metrics-store-endpoint.php
Outdated
Show resolved
Hide resolved
…s and add it separate method
Sorry, after merging #1905 there are now some merge conflicts that need to be resolved. I think the new function which was introduced in that PR should made a method of the class introduced here |
I'm working on resolving the merge conflicts. |
That was more difficult than I was expecting. |
…_update_actions()
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.
@hbhalodia Thank you for the many iterations on this!
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 @hbhalodia and @westonruter!
This looks good, just one point of feedback, but not a blocker for merge, though it would be great to follow up on this separately.
* @param WP_REST_Request $request Request used to generate the response. | ||
* @return mixed Passed through $result if successful, or otherwise a WP_Error. | ||
*/ | ||
public function decompress_rest_request_body( $result, WP_REST_Server $server, WP_REST_Request $request ) { |
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.
Having this in here doesn't seem ideal, since the method is not scoped to this endpoint (even though it technically only acts if the endpoint is hit).
So I think ideally this would be either a standalone function or in a general REST utility class with static methods.
Since it's marked private, not a blocker for merging, but wanted to flag. It could be refactored later.
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.
OK, I'll address in a follow-up I'm working on right now.
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.
See #1924
Thanks, @westonruter For updating the PR and apologies that I was not available last friday, hence was not able to pick the further feedbacks. |
Summary
Fixes #1859
Relevant technical choices
storage/rest-api.php
to class based approach and namedstorage/class-od-rest-api.php
.test-rest-api.php
totest-class-rest-api.php
.TODO
add_action( 'od_trigger_page_cache_invalidation', 'od_trigger_page_cache_invalidation' )
after refactor.