本文整理汇总了PHP中KTUtil::computePeriodToDate方法的典型用法代码示例。如果您正苦于以下问题:PHP KTUtil::computePeriodToDate方法的具体用法?PHP KTUtil::computePeriodToDate怎么用?PHP KTUtil::computePeriodToDate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KTUtil
的用法示例。
在下文中一共展示了KTUtil::computePeriodToDate方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getIndexStatistics
public function getIndexStatistics()
{
$optimisationDate = KTUtil::getSystemSetting('luceneOptimisationDate', '');
$noOptimisation = false;
if ($optimisationDate == '') {
$optimisationDate = _kt('N/A');
$optimisationPeriod = $optimisationDate;
} else {
$optimisationPeriod = KTUtil::computePeriodToDate($optimisationDate, null, true);
$noOptimisation = $optimisationPeriod['days'] > 2;
$optimisationPeriod = $optimisationPeriod['str'];
$optimisationDate = date('Y-m-d H:i:s', $optimisationDate);
}
$indexingDate = KTUtil::getSystemSetting('luceneIndexingDate', '');
if ($indexingDate == '') {
$indexingDate = _kt('N/A');
$indexingPeriod = $indexingDate;
} else {
$indexingPeriod = KTUtil::computePeriodToDate($indexingDate);
$indexingDate = date('Y-m-d H:i:s', $indexingDate);
}
$index = Indexer::get();
$docsInIndex = $index->getDocumentsInIndex();
// we are only interested in documents that are active
$sql = "SELECT count(*) as docsInQueue FROM index_files i inner join documents d on i.document_id = d.id where (i.status_msg is null or i.status_msg = '') and d.status_id=1";
$docsInQueue = DBUtil::getOneResultKey($sql, 'docsInQueue');
$sql = "SELECT count(*) as errorsInQueue FROM index_files i inner join documents d on i.document_id = d.id where (i.status_msg is not null or i.status_msg <> '') and d.status_id=1";
$errorsInQueue = DBUtil::getOneResultKey($sql, 'errorsInQueue');
$sql = "SELECT count(*) as docsInRepository FROM documents where status_id=1";
$docsInRepository = DBUtil::getOneResultKey($sql, 'docsInRepository');
if ($docsInRepository == 0) {
$indexingCoverage = '0.00%';
$queueCoverage = $indexingCoverage;
} else {
// compute indexing coverage
$indexingCoverage = _kt('Not Available');
if (is_numeric($docsInIndex)) {
$indexingCoverage = $docsInIndex * 100 / $docsInRepository;
$indexingCoverage = number_format($indexingCoverage, 2, '.', ',') . '%';
}
// compute queue coverage
$queueCoverage = _kt('Not Available');
if (is_numeric($docsInQueue)) {
$queueCoverage = $docsInQueue * 100 / $docsInRepository;
$queueCoverage = number_format($queueCoverage, 2, '.', ',') . '%';
}
}
$stats = array('optimisationDate' => $optimisationDate, 'optimisationPeriod' => $optimisationPeriod, 'indexingDate' => $indexingDate, 'indexingPeriod' => $indexingPeriod, 'docsInIndex' => $docsInIndex, 'docsInQueue' => $docsInQueue, 'errorsInQueue' => $errorsInQueue, 'docsInRepository' => $docsInRepository, 'indexingCoverage' => $indexingCoverage, 'queueCoverage' => $queueCoverage, 'noOptimisation' => $noOptimisation);
return $stats;
}