output overall stats of added, updated, unchanged docs and folders

This commit is contained in:
Uwe Steinmann 2022-07-28 11:59:27 +02:00
parent 3a4220fe18
commit b3cb5de21f

View File

@ -63,7 +63,7 @@ include($myincpath."/inc/inc.Extension.php");
include($myincpath."/inc/inc.DBInit.php");
function tree($dms, $fulltextservice, $folder, $indent='', $numdocs) { /* {{{ */
global $settings, $themes;
global $settings, $themes, $stats;
$index = $fulltextservice->Indexer();
$lucenesearch = $fulltextservice->Search();
@ -82,6 +82,7 @@ function tree($dms, $fulltextservice, $folder, $indent='', $numdocs) { /* {{{ */
}
$index->addDocument($idoc);
echo $themes->green(" (Folder added)").PHP_EOL;
$stats['folder']['add']++;
} catch(Exception $e) {
echo $themes->error(" (Timeout)").PHP_EOL;
}
@ -93,6 +94,7 @@ function tree($dms, $fulltextservice, $folder, $indent='', $numdocs) { /* {{{ */
}
if($created >= $folder->getDate()) {
echo $themes->italic(" (Folder unchanged)").PHP_EOL;
$stats['folder']['unchanged']++;
} else {
$index->delete($hit->id);
try {
@ -106,6 +108,7 @@ function tree($dms, $fulltextservice, $folder, $indent='', $numdocs) { /* {{{ */
}
$index->addDocument($idoc);
echo $themes->green(" (Folder updated)").PHP_EOL;
$stats['folder']['update']++;
} catch(Exception $e) {
echo $themes->error(" (Timeout)").PHP_EOL;
}
@ -132,6 +135,7 @@ function tree($dms, $fulltextservice, $folder, $indent='', $numdocs) { /* {{{ */
}
$index->addDocument($idoc);
echo $themes->green(" (Document added)").PHP_EOL;
$stats['document']['add']++;
} catch(Exception $e) {
echo $themes->error(" (Timeout)").PHP_EOL;
}
@ -144,6 +148,7 @@ function tree($dms, $fulltextservice, $folder, $indent='', $numdocs) { /* {{{ */
$content = $document->getLatestContent();
if($created >= $content->getDate()) {
echo $themes->italic(" (Document unchanged)").PHP_EOL;
$stats['document']['unchanged']++;
} else {
$index->delete($hit->id);
try {
@ -157,6 +162,7 @@ function tree($dms, $fulltextservice, $folder, $indent='', $numdocs) { /* {{{ */
}
$index->addDocument($idoc);
echo $themes->green(" (Document updated)").PHP_EOL;
$stats['document']['update']++;
} catch(Exception $e) {
echo $themes->error(" (Timeout)").PHP_EOL;
}
@ -173,6 +179,12 @@ if(!$index) {
exit(1);
}
$stats['folder']['add'] = 0;
$stats['folder']['unchanged'] = 0;
$stats['folder']['update'] = 0;
$stats['document']['add'] = 0;
$stats['document']['unchanged'] = 0;
$stats['document']['update'] = 0;
$numdocs = $fulltextservice->Indexer()->count();
$folder = $dms->getFolder($settings->_rootFolderID);
/* if numdocs is 0, then there is no need to check if a document/folder is already
@ -182,3 +194,13 @@ tree($dms, $fulltextservice, $folder,'', $numdocs);
$index->commit();
$index->optimize();
echo PHP_EOL;
echo $themes->black("Documents").PHP_EOL;
echo $themes->black(" added: ".$stats['document']['add']).PHP_EOL;
echo $themes->black(" updated: ".$stats['document']['update']).PHP_EOL;
echo $themes->black(" unchanged: ".$stats['document']['unchanged']).PHP_EOL;
echo $themes->black("Folders").PHP_EOL;
echo $themes->black(" added: ".$stats['folder']['add']).PHP_EOL;
echo $themes->black(" updated: ".$stats['folder']['update']).PHP_EOL;
echo $themes->black(" unchanged: ".$stats['folder']['unchanged']).PHP_EOL;