Skip to content
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

Reporting API: showColumns and hideColumns should be applied recursively #11100

Merged
merged 4 commits into from Dec 27, 2016

Conversation

mattab
Copy link
Member

@mattab mattab commented Dec 27, 2016

No description provided.

@mattab mattab added the Enhancement For new feature suggestions that enhance Matomo's capabilities or add a new report, new API etc. label Dec 27, 2016
@mattab mattab added this to the 3.0.1 milestone Dec 27, 2016
@mattab mattab merged commit 4dbf069 into 11066 Dec 27, 2016
@mattab mattab deleted the column_delete_recursive branch December 27, 2016 08:50
mattab added a commit that referenced this pull request Dec 27, 2016
…age generation time in Visitor Profile (#11095)

* Live API: New 'generationTimeMilliseconds' field used to process Average generation time in Visitor Profile
fixes #11066

* more precision

* Expected test files

* Reporting API: showColumns and hideColumns should be applied recursively (#11100)

* Recursively delete columns specified with hideColumns

* Custom Dimensions tests

* Invalid argument supplied for foreach() + Contents tests

* New unit test for ColumnDelete filter

* Submodules
@tsteur
Copy link
Member

tsteur commented Dec 27, 2016

If I get this PR right then this is quite a big breaking change I'd say in a 3.0.1 release. Definitely need to mention it in CHANGELOG and need to test all premium features again etc. It can be especially critical when there are different structures and suddenly eg rootTable or subtable doesn't contain any data anymore etc. Like subtables have different columns etc and showColumns/deleteColumns is used.

@tsteur
Copy link
Member

tsteur commented Dec 27, 2016

Such changes should always go through a review

*/
protected function removeColumnsFromTable(&$table)
{
if(!$this->isArrayAccess($table)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this really needed?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

without it there's a notice. it's quite weird how this filter is used on both DataTable (normal flow) and arrays (in ResponseBuilder)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not weird, it's the advantage of "interfaces" etc being able to treat them the same. It is now throwing notices probably since you start iterating nested on possible scalar values etc maybe

@tsteur
Copy link
Member

tsteur commented Dec 27, 2016

Also we return sometimes arrays with different structures in APIs. Eg like "getAvailablePatterns" and then root level of the array contains much different columns than children arrays. Ideally we also test Piwik Mobile with this change as it makes use of showColumns etc a lot to save data and for faster loading

}
}

$this->removeColumnsFromTable($table);
Copy link
Member

@tsteur tsteur Dec 27, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't enableRecursive() take care of this by calling filtersubtable? The nested part

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The enableRecursive does not function when the filter is applied to an array.

return;
}
foreach ($table as $index => &$row) {
if(!$this->isArrayAccess($row)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

whitespace after the if missing

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I presume you are doing this since it can now be a scalar etc. I'd definitely recommend testing performance for this. I remember from several performance profiles that showColumns/deleteColumns was always slow and one of the major contributors (like top 3 contributors) to slow performance in Piwik and now iterating over all array keys etc may make it much slower and we may want to find a different way for arrays vs dataTables etc.

@tsteur
Copy link
Member

tsteur commented Dec 27, 2016

Until performance is checked for this, and implications on breaking changes etc I'd rather revert this one

@mattab
Copy link
Member Author

mattab commented Dec 27, 2016

Updated demo.piwik.org to run 3.0.1-b1 and just tested Piwik Mobile 2 which seems to work fine (reports, Visitor log, Real time map). Is there some feature in particular we could test?

@tsteur
Copy link
Member

tsteur commented Dec 27, 2016

Need to test all features in Piwik Mobile and all premium features as it is a breaking API change and I can imagine that it may break something there. I can run the tests there later but should first also check re performance etc. Also it should be rather in a 3.1 release instead of 3.0.1. We didn't want to have any breaking changes in Piwik 3 and now we are starting to break in a patch release

@mattab
Copy link
Member Author

mattab commented Dec 27, 2016

It shouldn't be a breaking change unless relying on showColumns / hideColumns to not be recursive...

Just checked across premium plugins it seems we never use showColumns / hideColumns

What are your concerns re: performance? it shouldn't have any performance impact as it wouldn't load new sub-tables on demand or so. Only apply filter to any in-memory report.

Will add mention to Changelog and fix PSR.

fyi: Reason this was added now is because I wanted to do this so many times when having to hide columns from API response (eg. in tests) wouldn't hide all columns...

@tsteur
Copy link
Member

tsteur commented Dec 27, 2016

Only apply filter to any in-memory report.

Yes this is the SLOW part. In some cases took like 15-20% of the time and now doing much more might make it even slower.

It shouldn't be a breaking change unless relying on showColumns / hideColumns to not be recursive...

Calling the same API method the same way may return a different result. It is a breaking change by definition. Especially when having different data structures in root vs sub tables / arrays this can be a problem where it suddenly returns no data etc.

Just checked across premium plugins it seems we never use showColumns / hideColumns

They are sometimes applied by visualizations in Piwik, export feature maybe etc and mobile app etc.

@mattab
Copy link
Member Author

mattab commented Dec 27, 2016

see PR: #11106 - I did grep across whole codebase and concluded it appears to be safe and won't break our own plugins. Premium plugins should be especially safe unless I missed something... Would be good to re-run tests before release (due early Jan)

@tsteur
Copy link
Member

tsteur commented Dec 27, 2016

Piwik is a platform that other people rely on. We shouldn't only check whether it is only safe for us ;) Will re-run tests end this or next week.

mattab added a commit that referenced this pull request Dec 29, 2016
@mattab mattab mentioned this pull request Dec 29, 2016
@mattab mattab added the not-in-changelog For issues or pull requests that should not be included in our release changelog on matomo.org. label Dec 29, 2016
@mattab
Copy link
Member Author

mattab commented Dec 29, 2016

Will be reverted in #11113

mattab added a commit that referenced this pull request Dec 30, 2016
* Revert #11100

* Added new field <generationTimeMilliseconds> from #11095
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement For new feature suggestions that enhance Matomo's capabilities or add a new report, new API etc. not-in-changelog For issues or pull requests that should not be included in our release changelog on matomo.org.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants