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
New Command 'core:invalidate-report-data' to invalidate archive data (w/ period cascading) #8825
Conversation
Haven't tested it but LGTM. My usual comment: Would be nice to extract some private methods into other classes making them public and better (independent) testable but up to you :) |
Perhaps you could be more specific? If you have to repeat yourself, it means your method of communication isn't having the desired effect. One method is public in the command and is tested in a unit test. The others are only for processing input options. I don't know where to put those where they wouldn't just create clutter. Is there some symfony command way of defining those (ie, something like the DialogHelper) I am not aware of? |
I didn't mean the input ones sorry should have mentioned it in the code. Will leave some comments. I'm just personally trying to have as many public methods as possible so the methods are testable and reusable - if needed. Having one or two more classes should rather remove clutter from one big class instead of adding new clutter. |
$this->addPeriodsToCascadeOn($result, $childPeriodType, $startDate, $endDate); | ||
} | ||
|
||
private function getChildPeriod($periodType) |
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.
Maybe this could be moved into a period class? A switch
is most times a sign that one needs subclasses for each entity. So each period class could have a method getChildPeriod()
. So you get the Period class for your period via the factory and then call $period->getChildPeriod()
@tsteur Ok, I understand what you mean now. Some of your suggestions I can look into with this PR, others are unrelated. Also I don't consider them to be high value work, so I will probably create issues for them in the 3.0 branch I think most of these suggestions have to do w/ handling console input, really. Eg, getting & validating date ranges + idsites, etc. Perhaps we can create a custom symfony console helper for reuse. |
I think not all are console related. Eg the idSites check can be used in various scenarios but a console helper will be certainly nice 👍 |
Mentioned this at the end of the issue I created (when I realized this ;)). I'm not sure what a more "universal" concept would be though. Anyway not something I will work on now :) |
6fadd80
to
88f4a2f
Compare
@tsteur Moved some code into other places and added more tests, can you check that you see nothing wrong w/ the last couple commits? |
this command is useful, and it would be awesome to push the functionality down to the API. Can we enhance existing API call (documented in this FAQ and commonly used), or do we need to create new API? then it would make sense to even validate the inputs in API and move logic (eg. friendly error messages) from command to API. what do you think? |
Looking at the As per discussion:
|
@mattab what about invalidating single segment? |
@quba sounds good to me...eg. @diosmosis do you maybe want to look at adding |
Covered in #8858 |
88f4a2f
to
2050c9b
Compare
Should we maybe put the command |
Left a few comments but looks good to me |
@mattab can you answer this? |
58dd68f
to
7b29825
Compare
Command is too useful to have in a plugin, it must be in core for now. |
…chivesAsInvalidated (or whatever it's called) now returns an instance instead of an array of output messages.
…on test coming in later commit).
… new non-API method to Piwik Core.
…eriod class + add unit tests.
…ator then all periods are invalidated efficiently.
…::getAllParentPeriods and replace its use in ArchiveInvalidator w/ some small SQL changes.
… empty string & null.
7b29825
to
fdd3928
Compare
Command to invalidate archive data (w/ period cascading)
|
This PR contains a new command
core:invalidate-report-data
that provides a user friendly way to invalidate archive data (as an alternative to using the API multiple times).The command supports invalidating data for multiple sites, dates & periods and also supports cascading periods, so all child periods will be invalidated to. The command is smart enough to expand the range for child periods, so if a month is requested for invalidation, but it's first week has some days in the previous month, then those days will also be invalidated.
Also fixes #8858
TODO