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

ENH: Respect sort and limit arguments #158

Merged
merged 1 commit into from
Mar 10, 2022

Conversation

GuySartorelli
Copy link
Member

@GuySartorelli GuySartorelli commented Mar 6, 2022

These parameters are defined in the PHPDocs for Report and are technically part of the method signature. They should be respected and in the case of the new default limit in silverstripe/silverstripe-reports#139 this could have performance ramifications for large datasets.

Note that filterByCallback applies the limit from the DataList

@GuySartorelli GuySartorelli force-pushed the patch-1 branch 3 times, most recently from 4edf97b to caba703 Compare March 7, 2022 02:19
Copy link
Member

@emteknetnz emteknetnz left a comment

Choose a reason for hiding this comment

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

Seems reasonable

You'll also need to update the docblocks to include the new params

@GuySartorelli
Copy link
Member Author

GuySartorelli commented Mar 9, 2022

Updated dockblocks and fixed the $sort null check.

@GuySartorelli
Copy link
Member Author

GuySartorelli commented Mar 9, 2022

Fixed the test. The old code was calling sort but not actually using the resultant sorted list - so the test was asserting that an incorrect order was correct.
Not sure why the code wants to sort by parent ID in the first place though, tbf - @emteknetnz should I just revert the test back and remove the sort by ParentID line?

@emteknetnz
Copy link
Member

We should keep the default sort of ParentID so that it matches how it previously behaved

@GuySartorelli
Copy link
Member Author

GuySartorelli commented Mar 9, 2022

We should keep the default sort of ParentID so that it matches how it previously behaved

In that case we should remove that sort, because the previous behaviour wasn't actually sorting. Sort was called on the list but that returns a sorted list - it doesn't sort the list in place. And the sorted list wasn't used in the old code. So the actual list used for the report wasn't sorted.
I think? I could be missing something there.

@emteknetnz
Copy link
Member

emteknetnz commented Mar 9, 2022

Oh right, yes good point $records->sort("ParentID"); does nothing. Yes remove $sort = 'ParentID';

These parameters are defined in the PHPDocs for `Report` and are technically part of the method signature. They should be respected and in the case of the new default limit in silverstripe/silverstripe-reports#139 this could have performance ramifications for large datasets.
@GuySartorelli
Copy link
Member Author

GuySartorelli commented Mar 10, 2022

Removed the default sort, as it was a departure from the existing behaviour.

@emteknetnz emteknetnz merged commit 141e8d0 into silverstripe:4 Mar 10, 2022
@GuySartorelli GuySartorelli deleted the patch-1 branch March 10, 2022 20:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants