Esempio n. 1
0
 public function getCountCatalog($catalogGuid, $type)
 {
     $catalogs = App_Model_Show_Catalog::show()->getCatalogByGuid($catalogGuid);
     if ($catalogs && !in_array($catalogs['profileGuid'], array('partner', 'author', 'kategoriklinik'))) {
         switch ($type) {
             case 'desktop':
                 if (in_array($catalogs['profileGuid'], array('article', 'talks', 'isuhangat', 'kutu_agenda', 'video', 'infografis'))) {
                     $valueText = 'TICKER';
                 } else {
                     if ($catalogs['profileGuid'] == 'klinik') {
                         $valueText = 'klinik';
                     } else {
                         if (in_array($catalogs['profileGuid'], array('kutu_peraturan', 'kutu_rancangan_peraturan', 'kutu_peraturan_kolonial', 'kutu_putusan'))) {
                             $valueText = 'pusatdata';
                         }
                     }
                 }
                 break;
             case 'mobile':
                 if (in_array($catalogs['profileGuid'], array('article', 'talks', 'isuhangat', 'kutu_agenda', 'video', 'infografis'))) {
                     $valueText = 'TICKER-MOBILE';
                 } else {
                     if ($catalogs['profileGuid'] == 'klinik') {
                         $valueText = 'klinik-mobile';
                     } else {
                         if (in_array($catalogs['profileGuid'], array('kutu_peraturan', 'kutu_rancangan_peraturan', 'kutu_peraturan_kolonial', 'kutu_putusan'))) {
                             $valueText = 'pusatdata-mobile';
                         }
                     }
                 }
                 break;
         }
         $assetDb = new App_Model_Db_Table_AssetSetting();
         $assets = $assetDb->fetchRow("guid='{$catalogGuid}' AND valueText='{$valueText}'");
         if ($assets) {
             return $assets->valueInt;
         }
     }
     return;
 }
Esempio n. 2
0
 public function reIndexCatalog()
 {
     gc_enable();
     $this->emptyIndex();
     $time_start = microtime(true);
     $solr =& $this->_solr;
     $formater = new Pandamp_Lib_Formater();
     $title = new Pandamp_Controller_Action_Helper_GetCatalogTitle();
     //		$tbl = new Pandamp_Core_Orm_Table_Catalog();
     //		$rowset = $tbl->fetchAll(); //("profileGuid='Pandamp_peraturan'");
     $query = "SELECT * FROM KutuCatalog";
     $results = $this->_conn->query($query);
     $rowset = $results->fetchAll(PDO::FETCH_OBJ);
     $documents = array();
     $rowCount = count($rowset);
     for ($iCount = 0; $iCount < $rowCount; $iCount++) {
         $row = $rowset[$iCount];
         //			if($iCount == 100)
         //				break;
         //			echo 'urutan: '.$iCount .'<br>';
         $nextRow = $rowset[$iCount + 1];
         //			echo 'current guid: '.$row->guid.'  '.'next guid: '.$nextRow->guid.'<br>';
         if ($row->modifiedBy !== $row->createdBy) {
             $modified = '<font color=red>[modifiedBy:<i>' . $row->modifiedBy . '</i>]</font>&nbsp;';
         } else {
             $modified = '';
         }
         echo '<li><span style="font:11px verdana,arial,helvetica,sans-serif;">[urutan:' . $iCount . ']&nbsp;indexing:<font color=green>' . $title->getCatalogTitle($row->guid) . '</font>[current guid: ' . $row->guid . '  ' . 'next guid: ' . $nextRow->guid . '][author:<i>' . $row->createdBy . '</i>]&nbsp;' . $modified . '[createdDate:<i>' . $formater->get_date($row->createdDate) . '</i>]</span></li>';
         $documents[] = $this->_createSolrDocument($row);
         if ($iCount % 500 == 0) {
             try {
                 $solr->addDocuments($documents);
                 $solr->commit();
                 //					$solr->optimize();
                 $documents = array();
             } catch (Exception $e) {
                 //					echo "Error occured when processing record starting from number: ". ($iCount - 1000) . ' to '.$iCount.' '.$row->guid;
                 $log->err($e->getMessage());
                 throw new Zend_Exception($e->getMessage());
                 //					echo $e->getMessage().'<br>';
             }
         }
         flush();
     }
     echo '</ul></div></td></tr></table>';
     try {
         $solr->addDocuments($documents);
         $solr->commit();
         //			$solr->optimize();
     } catch (Exception $e) {
         $log->err($e->getMessage());
         throw new Zend_Exception($e->getMessage());
         //			echo $e->getMessage().'<br>';
     }
     $time_end = microtime(true);
     $time = $time_end - $time_start;
     //		echo'<br>WAKTU EKSEKUSI: '. $time;
     //		$log->info("WAKTU EKSEKUSI: ". $time." indexing catalog ".$iCount." dari ".$rowCount ." ".$username);
     echo '<br><br><span style="font:11px verdana,arial,helvetica,sans-serif;color:#00FF00">WAKTU EKSEKUSI: ' . $time . '<br>indexing catalog ' . $iCount . ' dari ' . $rowCount . '</span>';
     // log to assetSetting
     $tblAssetSetting = new App_Model_Db_Table_AssetSetting();
     $rowAsset = $tblAssetSetting->fetchRow("application='INDEX CATALOG'");
     if ($rowAsset) {
         $rowAsset->valueText = "Update {$rowCount} indexing-catalog at " . date("Y-m-d H:i:s") . $username;
         $rowAsset->valueInt = $rowAsset->valueInt + 1;
     } else {
         $gman = new Pandamp_Core_Guid();
         $catalogGuid = $gman->generateGuid();
         $rowAsset = $tblAssetSetting->fetchNew();
         $rowAsset->guid = $catalogGuid;
         $rowAsset->application = "INDEX CATALOG";
         $rowAsset->part = "KUTU";
         $rowAsset->valueType = "INDEX";
         $rowAsset->valueInt = 0;
         $rowAsset->valueText = $rowCount . " Indexing catalog at " . date("Y-m-d H:i:s") . $username;
     }
     $rowAsset->save();
 }