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
Add get-segment-sql development command for debugging #17461
Conversation
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 100% sure what is this for, but tested and got results that look ok to me 👍
plugins/SitesManager/Model.php
Outdated
@@ -240,7 +240,7 @@ public function getSiteFromId($idSite) | |||
* Returns the list of all the website IDs registered. | |||
* Caller must check access. | |||
* | |||
* @return array The list of website IDs | |||
* @return int[] The list of website IDs |
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.
That actually might not be correct. Depending on the mysql configuration it might be an array of strings. But guess we could add a cast to int in the foreach to ensure only ints are returned
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 could do int[]|string[]
. As long as it's not array
, it'll be more useful.
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.
Sure. no preference. Just wanted to mention that the return type can vary. Maybe casting to int would be even better, so we can rely on the return type?
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.
Might be more useful, but given we don't do that for any other query in Matomo (that I know of), I'm not sure it's really needed (and might make things more inconsistent).
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.
Feel free to change the doc block only then. Having more strict return types is a more global thing for sure 🙈
@flamisz segments are converted into SQL to select visits in Matomo, but for many segments the SQL is complicated and hard to imagine in your head (or mine at least), so the command prints it out so you can see how it's converted from a segment string (ie, |
Description:
Prints out the query of a segment, can be used if trying to determine if a segment is query is being built correctly or not.
Review