Skip to content
Snippets Groups Projects
Commit bb20c0cc authored by Giovannoni Laurent's avatar Giovannoni Laurent
Browse files

FEAT #5628

parent 1fb43679
No related branches found
No related tags found
No related merge requests found
...@@ -365,6 +365,9 @@ if ($_ENV['tablename'] == 'res_attachments' || $_ENV['tablename'] == 'res_versio ...@@ -365,6 +365,9 @@ if ($_ENV['tablename'] == 'res_attachments' || $_ENV['tablename'] == 'res_versio
$_ENV['logger']->write("docServers ".$_ENV['tablename']." found !"); $_ENV['logger']->write("docServers ".$_ENV['tablename']." found !");
$queryCount = "SELECT count(1) as count FROM "
. $_ENV['tablename'] . " WHERE (" . $fulltextColumnName . " = '0' or "
. $fulltextColumnName . " = '' or " . $fulltextColumnName . " is null) AND format = 'pdf'";
$queryIndexFullText = "SELECT res_id, docserver_id, path, filename, format FROM " $queryIndexFullText = "SELECT res_id, docserver_id, path, filename, format FROM "
. $_ENV['tablename'] . " WHERE (" . $fulltextColumnName . " = '0' or " . $_ENV['tablename'] . " WHERE (" . $fulltextColumnName . " = '0' or "
. $fulltextColumnName . " = '' or " . $fulltextColumnName . " is null) AND format = 'pdf'"; . $fulltextColumnName . " = '' or " . $fulltextColumnName . " is null) AND format = 'pdf'";
...@@ -372,28 +375,34 @@ if ($_ENV['tablename'] == 'res_attachments' || $_ENV['tablename'] == 'res_versio ...@@ -372,28 +375,34 @@ if ($_ENV['tablename'] == 'res_attachments' || $_ENV['tablename'] == 'res_versio
$_ENV['logger']->write("docServers ".$_ENV['tablename']." found !"); $_ENV['logger']->write("docServers ".$_ENV['tablename']." found !");
$queryCount = "SELECT count(1) as count FROM "
. $_ENV['tablename'] . " WHERE " . $fulltextColumnName . " = '0' or "
. $fulltextColumnName . " = '' or " . $fulltextColumnName . " is null ";
$queryIndexFullText = "SELECT res_id, docserver_id, path, filename, format FROM " $queryIndexFullText = "SELECT res_id, docserver_id, path, filename, format FROM "
. $_ENV['tablename'] . " WHERE " . $fulltextColumnName . " = '0' or " . $_ENV['tablename'] . " WHERE " . $fulltextColumnName . " = '0' or "
. $fulltextColumnName . " = '' or " . $fulltextColumnName . " is null "; . $fulltextColumnName . " = '' or " . $fulltextColumnName . " is null ";
} }
//$_ENV['logger']->write("query to found document with no full text : ".$queryIndexFullText); //$_ENV['logger']->write("query to found document with no full text : ".$queryIndexFullText);
$stmt = $_ENV['db']->query($queryIndexFullText); $stmt = $_ENV['db']->query($queryCount);
$cpt_batch_size=0; $cpt_batch_size=0;
//$_ENV['logger']->write("max_batch_size : ".$_ENV['max_batch_size']); //$_ENV['logger']->write("max_batch_size : ".$_ENV['max_batch_size']);
$nbResToFulltext = $stmt->fetchObject()->count;
if ($stmt->rowCount() === 0) { if ($nbResToFulltext === 0) {
Bt_exitBatch(0, 'No document to process'); Bt_exitBatch(0, 'No document to process');
}else{ }else{
$_ENV['logger']->write($stmt->rowCount().' document(s) to proceed.'); $_ENV['logger']->write($nbResToFulltext.' document(s) to proceed.');
} }
$stmt = $_ENV['db']->query($queryIndexFullText);
while ($queryResult=$stmt->fetch(PDO::FETCH_NUM)) { while ($queryResult=$stmt->fetch(PDO::FETCH_NUM)) {
if ($_ENV['max_batch_size'] >= $cpt_batch_size) { if ($_ENV['max_batch_size'] >= $cpt_batch_size) {
$pathToFile = $pathToDocServer[$queryResult[1]] $pathToFile = $pathToDocServer[$queryResult[1]]
. str_replace("#", DIRECTORY_SEPARATOR, $queryResult[2]) . str_replace("#", DIRECTORY_SEPARATOR, $queryResult[2])
. DIRECTORY_SEPARATOR . $queryResult[3]; . DIRECTORY_SEPARATOR . $queryResult[3];
$_ENV['logger']->write("processing of document ".($cpt_batch_size+1)."/".$stmt->rowCount()." (RES_ID => ". $queryResult[0] . ", FORMAT => ".$queryResult[4].", FILE => " . $pathToFile.")"); $_ENV['logger']->write("processing of document ".($cpt_batch_size+1)."/".$nbResToFulltext." (RES_ID => ". $queryResult[0] . ", FORMAT => ".$queryResult[4].", FILE => " . $pathToFile.")");
$result = indexFullText( $result = indexFullText(
$pathToFile, $indexFileDirectory, $queryResult[4], $queryResult[0] $pathToFile, $indexFileDirectory, $queryResult[4], $queryResult[0]
); );
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment