mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-24 10:23:17 +00:00
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:
@@ -951,7 +951,7 @@ class Databox implements ControllerProviderInterface
|
|||||||
$ret['sbas_id'] = $databox_id;
|
$ret['sbas_id'] = $databox_id;
|
||||||
$ret['xml_indexed'] = $datas['xml_indexed'];
|
$ret['xml_indexed'] = $datas['xml_indexed'];
|
||||||
$ret['thesaurus_indexed'] = $datas['thesaurus_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')) {
|
if ($app['filesystem']->exists($app['root.path'] . '/config/minilogos/logopdf_' . $databox_id . '.jpg')) {
|
||||||
$ret['printLogoURL'] = '/custom/minilogos/logopdf_' . $databox_id . '.jpg';
|
$ret['printLogoURL'] = '/custom/minilogos/logopdf_' . $databox_id . '.jpg';
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -410,14 +410,18 @@ class databox extends base
|
|||||||
|
|
||||||
public function get_indexed_record_amount()
|
public function get_indexed_record_amount()
|
||||||
{
|
{
|
||||||
|
|
||||||
$sql = "SELECT status & 3 AS status, SUM(1) AS n FROM record GROUP BY(status & 3)";
|
$sql = "SELECT status & 3 AS status, SUM(1) AS n FROM record GROUP BY(status & 3)";
|
||||||
$stmt = $this->get_connection()->prepare($sql);
|
$stmt = $this->get_connection()->prepare($sql);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||||
$stmt->closeCursor();
|
$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) {
|
foreach ($rs as $row) {
|
||||||
$status = $row['status'];
|
$status = $row['status'];
|
||||||
if ($status & 1)
|
if ($status & 1)
|
||||||
@@ -426,6 +430,21 @@ class databox extends base
|
|||||||
$ret['thesaurus_indexed'] += $row['n'];
|
$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;
|
return $ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -115,7 +115,8 @@ abstract class task_abstract
|
|||||||
protected $status;
|
protected $status;
|
||||||
protected $active;
|
protected $active;
|
||||||
protected $debug = false;
|
protected $debug = false;
|
||||||
protected $completed_percentage;
|
protected $todo;
|
||||||
|
protected $done;
|
||||||
protected $period = 60;
|
protected $period = 60;
|
||||||
protected $taskid = NULL;
|
protected $taskid = NULL;
|
||||||
protected $system = '';
|
protected $system = '';
|
||||||
@@ -144,7 +145,7 @@ abstract class task_abstract
|
|||||||
|
|
||||||
return '';
|
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';
|
FROM task2 WHERE task_id = :taskid';
|
||||||
$stmt = $conn->prepare($sql);
|
$stmt = $conn->prepare($sql);
|
||||||
$stmt->execute(array(':taskid' => $this->getID()));
|
$stmt->execute(array(':taskid' => $this->getID()));
|
||||||
@@ -158,7 +159,8 @@ abstract class task_abstract
|
|||||||
$this->active = ! ! $row['active'];
|
$this->active = ! ! $row['active'];
|
||||||
$this->settings = $row['settings'];
|
$this->settings = $row['settings'];
|
||||||
$this->runner = $row['runner'];
|
$this->runner = $row['runner'];
|
||||||
$this->completed_percentage = (int) $row['completed'];
|
$this->todo = (int) $row['todo'];
|
||||||
|
$this->done = (int) $row['done'];
|
||||||
$this->settings = $row['settings'];
|
$this->settings = $row['settings'];
|
||||||
|
|
||||||
if (false !== $sx = @simplexml_load_string($this->settings)) {
|
if (false !== $sx = @simplexml_load_string($this->settings)) {
|
||||||
@@ -389,9 +391,14 @@ abstract class task_abstract
|
|||||||
*
|
*
|
||||||
* @return int
|
* @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()
|
public static function getName()
|
||||||
@@ -682,10 +689,6 @@ abstract class task_abstract
|
|||||||
$rowstodo = count($rs);
|
$rowstodo = count($rs);
|
||||||
$rowsdone = 0;
|
$rowsdone = 0;
|
||||||
|
|
||||||
if ($rowstodo > 0) {
|
|
||||||
$this->setProgress(0, $rowstodo);
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach ($rs as $row) {
|
foreach ($rs as $row) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -696,7 +699,6 @@ abstract class task_abstract
|
|||||||
}
|
}
|
||||||
|
|
||||||
$this->records_done ++;
|
$this->records_done ++;
|
||||||
$this->setProgress($rowsdone, $rowstodo);
|
|
||||||
|
|
||||||
// post-process
|
// post-process
|
||||||
$this->postProcessOneContent($box, $row);
|
$this->postProcessOneContent($box, $row);
|
||||||
@@ -757,10 +759,6 @@ abstract class task_abstract
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($rowstodo > 0) {
|
|
||||||
$this->setProgress(0, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -905,18 +903,18 @@ abstract class task_abstract
|
|||||||
*/
|
*/
|
||||||
public function setProgress($done, $todo)
|
public function setProgress($done, $todo)
|
||||||
{
|
{
|
||||||
$p = ($todo > 0) ? ((100 * $done) / $todo) : -1;
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$conn = connection::getPDOConnection($this->dependencyContainer);
|
$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 = $conn->prepare($sql);
|
||||||
$stmt->execute(array(
|
$stmt->execute(array(
|
||||||
':p' => $p,
|
':todo' => $todo,
|
||||||
|
':done' => $done,
|
||||||
':taskid' => $this->getID()
|
':taskid' => $this->getID()
|
||||||
));
|
));
|
||||||
$stmt->closeCursor();
|
$stmt->closeCursor();
|
||||||
$this->completed_percentage = $p;
|
$this->todo = $todo;
|
||||||
|
$this->done = $done;
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -69,7 +69,8 @@ class task_manager
|
|||||||
'id' => $id,
|
'id' => $id,
|
||||||
'pid' => $task->getPID(),
|
'pid' => $task->getPID(),
|
||||||
'crashed' => $task->getCrashCounter(),
|
'crashed' => $task->getCrashCounter(),
|
||||||
'completed' => $task->getCompletedPercentage(),
|
'todo' => $task->getTodo(),
|
||||||
|
'done' => $task->getDone(),
|
||||||
'status' => $task->getState()
|
'status' => $task->getState()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,6 +32,8 @@ class task_period_subdef extends task_databoxAbstract
|
|||||||
|
|
||||||
protected $thumbnailExtraction;
|
protected $thumbnailExtraction;
|
||||||
|
|
||||||
|
private $_todo = 0; // set by "retrieveSbasContent", dec by "postProcessOneContent"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return about text
|
* Return about text
|
||||||
*
|
*
|
||||||
@@ -262,7 +264,7 @@ class task_period_subdef extends task_databoxAbstract
|
|||||||
|
|
||||||
$connbas = $databox->get_connection();
|
$connbas = $databox->get_connection();
|
||||||
|
|
||||||
$sql = 'SELECT coll_id, record_id
|
$sql = 'SELECT SQL_CALC_FOUND_ROWS record_id
|
||||||
FROM record
|
FROM record
|
||||||
WHERE jeton & ' . JETON_MAKE_SUBDEF . ' > 0
|
WHERE jeton & ' . JETON_MAKE_SUBDEF . ' > 0
|
||||||
ORDER BY record_id DESC LIMIT 0, '.$this->maxrecs;
|
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);
|
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||||
$stmt->closeCursor();
|
$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;
|
return $rs;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -308,6 +318,9 @@ class task_period_subdef extends task_databoxAbstract
|
|||||||
|
|
||||||
protected function postProcessOneContent(databox $databox, Array $row)
|
protected function postProcessOneContent(databox $databox, Array $row)
|
||||||
{
|
{
|
||||||
|
$this->_todo--;
|
||||||
|
$this->setProgress(0, $this->_todo);
|
||||||
|
|
||||||
$connbas = $databox->get_connection();
|
$connbas = $databox->get_connection();
|
||||||
$sql = 'UPDATE record
|
$sql = 'UPDATE record
|
||||||
SET jeton=(jeton & ~' . JETON_MAKE_SUBDEF . '), moddate=NOW()
|
SET jeton=(jeton & ~' . JETON_MAKE_SUBDEF . '), moddate=NOW()
|
||||||
|
|||||||
@@ -19,6 +19,8 @@ class task_period_writemeta extends task_databoxAbstract
|
|||||||
protected $clear_doc;
|
protected $clear_doc;
|
||||||
protected $metasubdefs = array();
|
protected $metasubdefs = array();
|
||||||
|
|
||||||
|
private $_todo = 0; // set by "retrieveSbasContent", dec by "postProcessOneContent"
|
||||||
|
|
||||||
public static function help()
|
public static function help()
|
||||||
{
|
{
|
||||||
return(_("task::writemeta:(re)ecriture des metadatas dans les documents (et subdefs concernees)"));
|
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;
|
$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)';
|
FROM record WHERE (jeton & ' . JETON_WRITE_META . ' > 0)';
|
||||||
|
|
||||||
$stmt = $connbas->prepare($sql);
|
$stmt = $connbas->prepare($sql);
|
||||||
@@ -230,6 +232,14 @@ class task_period_writemeta extends task_databoxAbstract
|
|||||||
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||||
$stmt->closeCursor();
|
$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;
|
return $rs;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -327,6 +337,9 @@ class task_period_writemeta extends task_databoxAbstract
|
|||||||
|
|
||||||
protected function postProcessOneContent(databox $databox, Array $row)
|
protected function postProcessOneContent(databox $databox, Array $row)
|
||||||
{
|
{
|
||||||
|
$this->_todo--;
|
||||||
|
$this->setProgress(0, $this->_todo);
|
||||||
|
|
||||||
$connbas = $databox->get_connection();
|
$connbas = $databox->get_connection();
|
||||||
|
|
||||||
$sql = 'UPDATE record SET jeton=jeton & ~' . JETON_WRITE_META . '
|
$sql = 'UPDATE record SET jeton=jeton & ~' . JETON_WRITE_META . '
|
||||||
|
|||||||
@@ -3404,14 +3404,22 @@
|
|||||||
<default></default>
|
<default></default>
|
||||||
<comment></comment>
|
<comment></comment>
|
||||||
</field>
|
</field>
|
||||||
<field>
|
<field>
|
||||||
<name>completed</name>
|
<name>todo</name>
|
||||||
<type>tinyint(4)</type>
|
<type>int(11)</type>
|
||||||
<null></null>
|
<null></null>
|
||||||
<extra></extra>
|
<extra></extra>
|
||||||
<default>-1</default>
|
<default>0</default>
|
||||||
<comment></comment>
|
<comment></comment>
|
||||||
</field>
|
</field>
|
||||||
|
<field>
|
||||||
|
<name>done</name>
|
||||||
|
<type>int(11)</type>
|
||||||
|
<null></null>
|
||||||
|
<extra></extra>
|
||||||
|
<default>0</default>
|
||||||
|
<comment></comment>
|
||||||
|
</field>
|
||||||
<field>
|
<field>
|
||||||
<name>runner</name>
|
<name>runner</name>
|
||||||
<type>char(20)</type>
|
<type>char(20)</type>
|
||||||
|
|||||||
@@ -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>)
|
(<a href="{{ path('admin_database_display_document_details', {'databox_id': databox.get_sbas_id()}) }}" class="ajax" target="rights">{% trans 'phraseanet:: details'%}</a>)
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
|
<li>
|
||||||
|
{% trans 'admin::base: subdefs to be created :' %}
|
||||||
|
<span id="subdefs_todo"></span>
|
||||||
|
</li>
|
||||||
|
|
||||||
{% if showDetail %}
|
{% if showDetail %}
|
||||||
<li>
|
<li>
|
||||||
{% trans 'admin::base: nombre de mots uniques sur la base : ' %}
|
{% trans 'admin::base: nombre de mots uniques sur la base : ' %}
|
||||||
@@ -276,6 +281,13 @@
|
|||||||
p = 100*data.thesaurus_indexed/data.records;
|
p = 100*data.thesaurus_indexed/data.records;
|
||||||
$("#thesaurus_indexed_bar").width(Math.round(2*p));
|
$("#thesaurus_indexed_bar").width(Math.round(2*p));
|
||||||
$("#thesaurus_indexed_percent").text((Math.round(p*100)/100)+" %");
|
$("#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)
|
if(data.printLogoURL)
|
||||||
|
|||||||
@@ -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"><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="STATUS_{{ task.getID() }}"></td>
|
||||||
<td style="text-align:center" id="PID_{{ task.getID() }}"> </td>
|
<td style="text-align:center" id="PID_{{ task.getID() }}"> </td>
|
||||||
<td>
|
<td style="text-align:center" id="TODO_{{ task.getID() }}" > </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 class="taskname">{{ task.getTitle() }} [{{ task.getName() }}]</td>
|
<td class="taskname">{{ task.getTitle() }} [{{ task.getName() }}]</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
@@ -202,15 +195,13 @@
|
|||||||
$("#WARNING_"+id).hide();
|
$("#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 + "%");
|
$("#TODO_"+id).html(ret.tasks[id].todo);
|
||||||
$("#COMPBOX_"+id).show();
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$("#COMPBOX_"+id).hide();
|
$("#TODO_"+id).html("-");
|
||||||
$("#COMP_"+id).width('0px');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user