Commit 536f9aa8020003db616e5f7eb65031252e53ea03
1 parent
2c63bf40
KTS-2471
"create search2 dashets" Updated. Committed By: Conrad Vermeulen Reviewed By: Kevin Fourie git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@7356 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
1 changed file
with
45 additions
and
1 deletions
plugins/search2/MigrationDashlet.php
| ... | ... | @@ -44,6 +44,14 @@ class LuceneMigrationDashlet extends KTBaseDashlet |
| 44 | 44 | return false; |
| 45 | 45 | } |
| 46 | 46 | |
| 47 | + $sql = "select count(*) as no from document_text"; | |
| 48 | + $no = DBUtil::getOneResultKey($sql,'no'); | |
| 49 | + if ($no == 0) | |
| 50 | + { | |
| 51 | + return false; | |
| 52 | + } | |
| 53 | + $this->migratingDocuments = $no; | |
| 54 | + | |
| 47 | 55 | return true; |
| 48 | 56 | } |
| 49 | 57 | |
| ... | ... | @@ -52,8 +60,44 @@ class LuceneMigrationDashlet extends KTBaseDashlet |
| 52 | 60 | $oTemplating =& KTTemplating::getSingleton(); |
| 53 | 61 | $oTemplate = $oTemplating->loadTemplate('ktcore/search2/lucene_migration'); |
| 54 | 62 | |
| 63 | + $config = KTConfig::getSingleton(); | |
| 64 | + $batchDocuments = $config->get('indexer/batchMigrateDocuments'); | |
| 65 | + | |
| 66 | + | |
| 67 | + $migratedDocuments = KTUtil::getSystemSetting('migratedDocuments',0); | |
| 68 | + $migratingDocuments = $this->migratingDocuments; | |
| 69 | + | |
| 70 | + $migrationStart = KTUtil::getSystemSetting('migrationStarted'); | |
| 71 | + if (is_null($migrationStart)) | |
| 72 | + { | |
| 73 | + $migrationStartString = _kt('Not started'); | |
| 74 | + $migrationPeriod = _kt('N/A'); | |
| 75 | + $estimatedTime = _kt('Unknown'); | |
| 76 | + $estimatedPeriod = $estimatedTime; | |
| 77 | + } | |
| 78 | + else | |
| 79 | + { | |
| 80 | + $migrationStartString = date('Y-m-d H:i:s', $migrationStart); | |
| 81 | + $migrationTime = KTUtil::getSystemSetting('migrationTime',0); | |
| 82 | + $migrationPeriod = KTUtil::computePeriod($migrationTime, ''); | |
| 83 | + $timePerDocument = $migrationTime / $migratedDocuments; | |
| 84 | + $estimatedPeriod = $timePerDocument * $migratingDocuments; | |
| 85 | + $estimatedTime = date('Y-m-d H:i:s', $migrationStart + $estimatedPeriod); | |
| 86 | + $estimatedPeriod = KTUtil::computePeriod($estimatedPeriod, ''); | |
| 87 | + } | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 55 | 91 | $aTemplateData = array( |
| 56 | - 'context' => $this | |
| 92 | + 'context' => $this, | |
| 93 | + 'batchDocuments'=>$batchDocuments, | |
| 94 | + 'batchPeriod'=>'Periodically', | |
| 95 | + 'migrationStart'=>$migrationStartString, | |
| 96 | + 'migrationPeriod'=>$migrationPeriod, | |
| 97 | + 'migratedDocuments'=>$migratedDocuments, | |
| 98 | + 'migratingDocuments'=>$migratingDocuments, | |
| 99 | + 'estimatedTime'=>$estimatedTime, | |
| 100 | + 'estimatedPeriod'=>$estimatedPeriod | |
| 57 | 101 | ); |
| 58 | 102 | |
| 59 | 103 | return $oTemplate->render($aTemplateData); | ... | ... |