diff --git a/lib/Alchemy/Phrasea/Controller/Admin/Databox.php b/lib/Alchemy/Phrasea/Controller/Admin/Databox.php index be414f3a90..89dbf4e695 100644 --- a/lib/Alchemy/Phrasea/Controller/Admin/Databox.php +++ b/lib/Alchemy/Phrasea/Controller/Admin/Databox.php @@ -951,7 +951,7 @@ class Databox implements ControllerProviderInterface $ret['sbas_id'] = $databox_id; $ret['xml_indexed'] = $datas['xml_indexed']; $ret['thesaurus_indexed'] = $datas['thesaurus_indexed']; - + $ret['jeton_subdef'] = $datas['jeton_subdef']; if ($app['filesystem']->exists($app['root.path'] . '/config/minilogos/logopdf_' . $databox_id . '.jpg')) { $ret['printLogoURL'] = '/custom/minilogos/logopdf_' . $databox_id . '.jpg'; } diff --git a/lib/classes/databox.php b/lib/classes/databox.php index 1369b4768b..63dfd78518 100644 --- a/lib/classes/databox.php +++ b/lib/classes/databox.php @@ -410,14 +410,18 @@ class databox extends base public function get_indexed_record_amount() { - $sql = "SELECT status & 3 AS status, SUM(1) AS n FROM record GROUP BY(status & 3)"; $stmt = $this->get_connection()->prepare($sql); $stmt->execute(); $rs = $stmt->fetchAll(PDO::FETCH_ASSOC); $stmt->closeCursor(); - $ret = array('xml_indexed' => 0, 'thesaurus_indexed' => 0); + $ret = array( + 'xml_indexed' => 0, + 'thesaurus_indexed' => 0, + 'jeton_subdef' => array() + ); + foreach ($rs as $row) { $status = $row['status']; if ($status & 1) @@ -426,6 +430,21 @@ class databox extends base $ret['thesaurus_indexed'] += $row['n']; } + $sql = "SELECT type, jeton, COUNT(record_id) AS n FROM record WHERE jeton & ".JETON_MAKE_SUBDEF." GROUP BY type, jeton"; + $stmt = $this->get_connection()->prepare($sql); + $stmt->execute(); + $rs = $stmt->fetchAll(PDO::FETCH_ASSOC); + $stmt->closeCursor(); + + foreach ($rs as $row) { + if(!array_key_exists($row['type'], $ret['jeton_subdef'])) { + $ret['jeton_subdef'][$row['type']] = 0; + } + if((int)$row['jeton'] & JETON_MAKE_SUBDEF) { + $ret['jeton_subdef'][$row['type']] += (int)$row['n']; + } + } + return $ret; } diff --git a/lib/classes/task/abstract.php b/lib/classes/task/abstract.php index 8bf5a2f3d5..e442cf64ac 100644 --- a/lib/classes/task/abstract.php +++ b/lib/classes/task/abstract.php @@ -115,7 +115,8 @@ abstract class task_abstract protected $status; protected $active; protected $debug = false; - protected $completed_percentage; + protected $todo; + protected $done; protected $period = 60; protected $taskid = NULL; protected $system = ''; @@ -144,7 +145,7 @@ abstract class task_abstract return ''; } - $sql = 'SELECT crashed, pid, status, active, settings, name, completed, runner + $sql = 'SELECT crashed, pid, status, active, settings, name, todo, done, runner FROM task2 WHERE task_id = :taskid'; $stmt = $conn->prepare($sql); $stmt->execute(array(':taskid' => $this->getID())); @@ -158,7 +159,8 @@ abstract class task_abstract $this->active = ! ! $row['active']; $this->settings = $row['settings']; $this->runner = $row['runner']; - $this->completed_percentage = (int) $row['completed']; + $this->todo = (int) $row['todo']; + $this->done = (int) $row['done']; $this->settings = $row['settings']; if (false !== $sx = @simplexml_load_string($this->settings)) { @@ -389,9 +391,14 @@ abstract class task_abstract * * @return int */ - public function getCompletedPercentage() + public function getTodo() { - return $this->completed_percentage; + return $this->todo; + } + + public function getDone() + { + return $this->done; } public static function getName() @@ -682,10 +689,6 @@ abstract class task_abstract $rowstodo = count($rs); $rowsdone = 0; - if ($rowstodo > 0) { - $this->setProgress(0, $rowstodo); - } - foreach ($rs as $row) { try { @@ -696,7 +699,6 @@ abstract class task_abstract } $this->records_done ++; - $this->setProgress($rowsdone, $rowstodo); // post-process $this->postProcessOneContent($box, $row); @@ -757,10 +759,6 @@ abstract class task_abstract } } - if ($rowstodo > 0) { - $this->setProgress(0, 0); - } - return $ret; } @@ -905,18 +903,18 @@ abstract class task_abstract */ public function setProgress($done, $todo) { - $p = ($todo > 0) ? ((100 * $done) / $todo) : -1; - try { $conn = connection::getPDOConnection($this->dependencyContainer); - $sql = 'UPDATE task2 SET completed = :p WHERE task_id = :taskid'; + $sql = 'UPDATE task2 SET todo = :todo, done = :done WHERE task_id = :taskid'; $stmt = $conn->prepare($sql); $stmt->execute(array( - ':p' => $p, + ':todo' => $todo, + ':done' => $done, ':taskid' => $this->getID() )); $stmt->closeCursor(); - $this->completed_percentage = $p; + $this->todo = $todo; + $this->done = $done; } catch (\Exception $e) { } diff --git a/lib/classes/task/manager.php b/lib/classes/task/manager.php index 1f090c5000..3afd168f48 100644 --- a/lib/classes/task/manager.php +++ b/lib/classes/task/manager.php @@ -69,7 +69,8 @@ class task_manager 'id' => $id, 'pid' => $task->getPID(), 'crashed' => $task->getCrashCounter(), - 'completed' => $task->getCompletedPercentage(), + 'todo' => $task->getTodo(), + 'done' => $task->getDone(), 'status' => $task->getState() ); } diff --git a/lib/classes/task/period/subdef.php b/lib/classes/task/period/subdef.php index 8311f6352d..c46241f0a2 100644 --- a/lib/classes/task/period/subdef.php +++ b/lib/classes/task/period/subdef.php @@ -32,6 +32,8 @@ class task_period_subdef extends task_databoxAbstract protected $thumbnailExtraction; + private $_todo = 0; // set by "retrieveSbasContent", dec by "postProcessOneContent" + /** * Return about text * @@ -262,7 +264,7 @@ class task_period_subdef extends task_databoxAbstract $connbas = $databox->get_connection(); - $sql = 'SELECT coll_id, record_id + $sql = 'SELECT SQL_CALC_FOUND_ROWS record_id FROM record WHERE jeton & ' . JETON_MAKE_SUBDEF . ' > 0 ORDER BY record_id DESC LIMIT 0, '.$this->maxrecs; @@ -271,6 +273,14 @@ class task_period_subdef extends task_databoxAbstract $rs = $stmt->fetchAll(PDO::FETCH_ASSOC); $stmt->closeCursor(); + $sql = 'SELECT FOUND_ROWS()'; + $stmt = $connbas->prepare($sql); + $stmt->execute(); + $this->_todo = (int) $stmt->fetchColumn(0); + $stmt->closeCursor(); + + $this->setProgress(0, $this->_todo); + return $rs; } @@ -308,6 +318,9 @@ class task_period_subdef extends task_databoxAbstract protected function postProcessOneContent(databox $databox, Array $row) { + $this->_todo--; + $this->setProgress(0, $this->_todo); + $connbas = $databox->get_connection(); $sql = 'UPDATE record SET jeton=(jeton & ~' . JETON_MAKE_SUBDEF . '), moddate=NOW() diff --git a/lib/classes/task/period/writemeta.php b/lib/classes/task/period/writemeta.php index 9a08f152f0..9306310a86 100644 --- a/lib/classes/task/period/writemeta.php +++ b/lib/classes/task/period/writemeta.php @@ -19,6 +19,8 @@ class task_period_writemeta extends task_databoxAbstract protected $clear_doc; protected $metasubdefs = array(); + private $_todo = 0; // set by "retrieveSbasContent", dec by "postProcessOneContent" + public static function help() { return(_("task::writemeta:(re)ecriture des metadatas dans les documents (et subdefs concernees)")); @@ -222,7 +224,7 @@ class task_period_writemeta extends task_databoxAbstract $this->metasubdefs = $metasubdefs; - $sql = 'SELECT record_id, coll_id, jeton + $sql = 'SELECT SQL_CALC_FOUND_ROWS record_id, coll_id, jeton FROM record WHERE (jeton & ' . JETON_WRITE_META . ' > 0)'; $stmt = $connbas->prepare($sql); @@ -230,6 +232,14 @@ class task_period_writemeta extends task_databoxAbstract $rs = $stmt->fetchAll(PDO::FETCH_ASSOC); $stmt->closeCursor(); + $sql = 'SELECT FOUND_ROWS()'; + $stmt = $connbas->prepare($sql); + $stmt->execute(); + $this->_todo = (int) $stmt->fetchColumn(0); + $stmt->closeCursor(); + + $this->setProgress(0, $this->_todo); + return $rs; } @@ -327,6 +337,9 @@ class task_period_writemeta extends task_databoxAbstract protected function postProcessOneContent(databox $databox, Array $row) { + $this->_todo--; + $this->setProgress(0, $this->_todo); + $connbas = $databox->get_connection(); $sql = 'UPDATE record SET jeton=jeton & ~' . JETON_WRITE_META . ' diff --git a/lib/conf.d/bases_structure.xml b/lib/conf.d/bases_structure.xml index 0072184b09..c7f0435b9a 100644 --- a/lib/conf.d/bases_structure.xml +++ b/lib/conf.d/bases_structure.xml @@ -3404,14 +3404,22 @@ - - completed - tinyint(4) - - - -1 - - + + todo + int(11) + + + 0 + + + + done + int(11) + + + 0 + + runner char(20) diff --git a/templates/web/admin/databox/databox.html.twig b/templates/web/admin/databox/databox.html.twig index f8685fb33d..177493dc7f 100644 --- a/templates/web/admin/databox/databox.html.twig +++ b/templates/web/admin/databox/databox.html.twig @@ -50,6 +50,11 @@ ({% trans 'phraseanet:: details'%}) +
  • + {% trans 'admin::base: subdefs to be created :' %} + +
  • + {% if showDetail %}
  • {% trans 'admin::base: nombre de mots uniques sur la base : ' %} @@ -276,6 +281,13 @@ p = 100*data.thesaurus_indexed/data.records; $("#thesaurus_indexed_bar").width(Math.round(2*p)); $("#thesaurus_indexed_percent").text((Math.round(p*100)/100)+" %"); + + var t = ""; + for(var i in data.jeton_subdef) + { + t += (t==""?"":" ; ") + i + ": " + data.jeton_subdef[i]; + } + $("#subdefs_todo").text(t); } if(data.printLogoURL) diff --git a/templates/web/admin/tasks/list.html.twig b/templates/web/admin/tasks/list.html.twig index abf6a08fdf..10e34aa8e4 100644 --- a/templates/web/admin/tasks/list.html.twig +++ b/templates/web/admin/tasks/list.html.twig @@ -70,14 +70,7 @@   - -
    -
    -
    -
    -
    -
    - +   {{ task.getTitle() }} [{{ task.getName() }}] {% endfor %} @@ -202,15 +195,13 @@ $("#WARNING_"+id).hide(); } - if(ret.tasks[id].completed && ret.tasks[id].completed>0 && ret.tasks[id].completed<=100) + if(ret.tasks[id].todo > 0) { - $("#COMP_"+id).width(ret.tasks[id].completed + "%"); - $("#COMPBOX_"+id).show(); + $("#TODO_"+id).html(ret.tasks[id].todo); } else { - $("#COMPBOX_"+id).hide(); - $("#COMP_"+id).width('0px'); + $("#TODO_"+id).html("-"); } } }