Skip to content
Snippets Groups Projects
Commit b396d270 authored by Patrick Barroca's avatar Patrick Barroca :grin:
Browse files

rel #28103 : Pseudo-records indexing batch handled with progressbar

parent ac555e11
Branches
Tags
4 merge requests!1267Master,!1221Master,!1220Hotline master,!1205Hotline#28103 les vignettes d album 1dtouch ne s affichent pas
......@@ -7,7 +7,7 @@ echo $this->bouton('id=add',
);
echo $this->tagModelTable(
$this->batchs,
$this->batchs,
[$this->_('Libelle'), $this->_('Dernière exécution')],
['Libelle', 'last_run'],
[
......@@ -16,12 +16,13 @@ echo $this->tagModelTable(
if ('MOISSONNAGE_CYBERLIBRIS' == $batch->getType())
return '';
$action = (in_array($batch->getType(),
['AUTOCOMPLETE_RECORD_TITLE', 'AUTOCOMPLETE_RECORD_AUTHOR'])) ?
'run-ajax' : 'run';
return $this->tagAnchor(['action' => $action, 'id' => $batch->getId()],
$action = (in_array($batch->getType(),
['AUTOCOMPLETE_RECORD_TITLE',
'AUTOCOMPLETE_RECORD_AUTHOR',
'INDEX_RESSOURCES_NUMERIQUES'])) ?
'run-ajax' : 'run';
return $this->tagAnchor(['action' => $action, 'id' => $batch->getId()],
$this->boutonIco('type=test', 'bulle=Lancer'));
}],
'batchs');
?>
......@@ -7,9 +7,10 @@ class Class_Batch_IndexRessourcesNumeriques extends Class_Batch_Abstract {
return $this->_("Indexer les ressources numériques");
}
public function run() {
$current_page = -1;
do {
do {
$albums = Class_Album::findAllBy(['limitPage' => [$current_page += 1,
100]]);
foreach ($albums as $album)
......@@ -24,6 +25,32 @@ class Class_Batch_IndexRessourcesNumeriques extends Class_Batch_Abstract {
(new Storm_Cache())->clean();
}
public function runStep($params) {
$response = new stdClass;
if (empty($params) || !isset($params['done'])) {
$response->done = 0;
$response->total= 0;
return $response;
}
$done = $params['done'];
$page_size = 100;
$page = ($done / $page_size) + 1;
$response->total = Class_Album::count();
$models = Class_Album::findAllBy(['limitPage' => [$page, $page_size]]);
foreach($models as $models)
$models->index();
$response->done = ($response->total > $done + $page_size) ?
$done + $page_size :
$done + count($models);
return $response;
}
public function isEnabled() {
$types = Class_Batch::getRessourcesNumeriqueTypes();
foreach ($types as $instance) {
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment