From 4961430c8fcf0f0d24d63e24b0341a5274401c42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Hru=C5=A1ka?= Date: Sat, 11 Aug 2018 22:01:45 +0200 Subject: [PATCH] also order exports --- app/Tables/BaseExporter.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/app/Tables/BaseExporter.php b/app/Tables/BaseExporter.php index 6671d0e..b830aaa 100644 --- a/app/Tables/BaseExporter.php +++ b/app/Tables/BaseExporter.php @@ -127,10 +127,15 @@ abstract class BaseExporter $count = $revision->rows()->count(); $start = 0; + $rq = $revision->rowsData($this->columns, false); + + $columns = $this->columns; + + // TODO raw query to allow selecting aggregates, column subsets, etc + if (count($columns)) $rq = $rq->orderByRaw("data->>'".$columns[0]->id."'"); + while ($start < $count) { - // TODO raw query to allow selecting aggregates, column subsets, etc - $rows = $revision->rowsData($this->columns, false) - ->offset($start)->limit($chunkSize)->get()->toArray(); + $rows = $rq->offset($start)->limit($chunkSize)->get()->toArray(); foreach ($rows as $row) { unset($row['_row_pivot']);