Slight refactor of set_export to avoid N+1

This commit is contained in:
Benoît Burnichon
2016-05-20 10:18:30 +02:00
parent edaf603552
commit db3bb2d4c4
2 changed files with 10 additions and 13 deletions

View File

@@ -68,8 +68,6 @@ class record_exportElement extends record_adapter
parent::__construct($app, $sbas_id, $record_id); parent::__construct($app, $sbas_id, $record_id);
$this->get_actions($remain_hd); $this->get_actions($remain_hd);
return $this;
} }
/** /**
@@ -270,8 +268,7 @@ class record_exportElement extends record_adapter
} }
/** /**
* * @return array
* @return Array
*/ */
public function get_orderable() public function get_orderable()
{ {
@@ -279,8 +276,7 @@ class record_exportElement extends record_adapter
} }
/** /**
* * @return array
* @return Array
*/ */
public function get_downloadable() public function get_downloadable()
{ {

View File

@@ -99,19 +99,20 @@ class set_export extends set_abstract
} else { } else {
$this->exportName = "Export_" . date("Y-n-d") . '_' . mt_rand(100, 999); $this->exportName = "Export_" . date("Y-n-d") . '_' . mt_rand(100, 999);
$tmp_lst = explode(';', $lst);
$n = 1; $n = 1;
foreach ($tmp_lst as $basrec) {
$basrec = explode('_', $basrec);
if (count($basrec) != 2)
continue;
$records = new \Alchemy\Phrasea\Record\RecordReferenceCollection();
foreach (explode(';', $lst) as $basrec) {
try { try {
$record = new record_adapter($this->app, $basrec[0], $basrec[1]); $records[] = \Alchemy\Phrasea\Record\RecordReference::createFromRecordReference($basrec);
} catch (\Exception_Record_AdapterNotFound $e) { } catch (Exception $exception) {
// Ignore invalid record references
continue; continue;
} }
}
foreach ($records->toRecords($app->getApplicationBox()) as $record) {
if ($record->isStory()) { if ($record->isStory()) {
foreach ($record->getChildren() as $child_basrec) { foreach ($record->getChildren() as $child_basrec) {
$base_id = $child_basrec->getBaseId(); $base_id = $child_basrec->getBaseId();