Skip to content

Commit

Permalink
ENH: Respect sort and limit arguments
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
GuySartorelli authored Mar 6, 2022
1 parent 46a637a commit 46f70c4
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/Reports/PagesWithoutReviewScheduleReport.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public function columns()
*
* @return SS_List
*/
public function sourceRecords($params = [])
public function sourceRecords($params = [], $sort = null, $limit = null)
{
Versioned::set_stage(Versioned::DRAFT);

Expand All @@ -125,7 +125,13 @@ public function sourceRecords($params = [])
));
}

$records->sort("ParentID");
if ($sort !== null) {
$sort = 'ParentID';
}
$records->sort($sort);
if ($limit !== null) {
$records = $records->limit($limit);
}
$records = $records->toArray();

// Trim out calculated values
Expand Down

0 comments on commit 46f70c4

Please sign in to comment.