Merge pull request #1118 from jygaulier/3.8-PHRAS-64

[3.8.6][PHRAS-64] Delete progression of subdef task, print the number of remaining subdefs to do
This commit is contained in:
Nicolas Le Goff
2014-08-22 18:49:38 +02:00
9 changed files with 101 additions and 46 deletions

View File

@@ -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';
}

View File

@@ -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;
}

View File

@@ -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) {
}

View File

@@ -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()
);
}

View File

@@ -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()

View File

@@ -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 . '

View File

@@ -3405,11 +3405,19 @@
<comment></comment>
</field>
<field>
<name>completed</name>
<type>tinyint(4)</type>
<name>todo</name>
<type>int(11)</type>
<null></null>
<extra></extra>
<default>-1</default>
<default>0</default>
<comment></comment>
</field>
<field>
<name>done</name>
<type>int(11)</type>
<null></null>
<extra></extra>
<default>0</default>
<comment></comment>
</field>
<field>

View File

@@ -50,6 +50,11 @@
(<a href="{{ path('admin_database_display_document_details', {'databox_id': databox.get_sbas_id()}) }}" class="ajax" target="rights">{% trans 'phraseanet:: details'%}</a>)
</li>
<li>
{% trans 'admin::base: subdefs to be created :' %}
<span id="subdefs_todo"></span>
</li>
{% if showDetail %}
<li>
{% 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)

View File

@@ -70,14 +70,7 @@
<td style="text-align:center"><img id="WARNING_{{ task.getID() }}" src="/skins/icons/alert.png" title="" style="display:none;"/></td>
<td style="text-align:center" id="STATUS_{{ task.getID() }}"></td>
<td style="text-align:center" id="PID_{{ task.getID() }}">&nbsp;</td>
<td>
<div style="position:relative; top:0px; left:0px; right:0px;" >
<div id="COMPBOX_{{ task.getID() }}" style="position:absolute; top:1px; left:3px; right:3px; height:5px; background-color:#787878">
<div id="COMP_{{ task.getID() }}" style="position:absolute; top:1px; left:0px; width:0%; height:3px; background-color:#FFFF80">
</div>
</div>
</div>
</td>
<td style="text-align:center" id="TODO_{{ task.getID() }}" >&nbsp;</td>
<td class="taskname">{{ task.getTitle() }} [{{ task.getName() }}]</td>
</tr>
{% 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("-");
}
}
}