/** * Builds the SELECT part of the Index Queue initialization query. * */ protected function buildSelectStatement() { $changedField = $GLOBALS['TCA'][$this->type]['ctrl']['tstamp']; if (!empty($GLOBALS['TCA'][$this->type]['ctrl']['enablecolumns']['starttime'])) { $changedField = 'GREATEST(' . $GLOBALS['TCA'][$this->type]['ctrl']['enablecolumns']['starttime'] . ',' . $GLOBALS['TCA'][$this->type]['ctrl']['tstamp'] . ')'; } $select = 'SELECT ' . '\'' . $this->site->getRootPageId() . '\' as root, ' . '\'' . $this->type . '\' AS item_type, ' . 'uid AS item_uid, ' . '\'' . $this->indexingConfigurationName . '\' as indexing_configuration, ' . $this->getIndexingPriority() . ' AS indexing_priority, ' . $changedField . ' AS changed'; return $select; }
/** * Gets the indexing progress. * * @return float Indexing progress as a two decimal precision float. f.e. 44.87 */ public function getProgress() { $itemsIndexedPercentage = 0.0; $totalItemsCount = $GLOBALS['TYPO3_DB']->exec_SELECTcountRows('uid', 'tx_solr_indexqueue_item', 'root = ' . $this->site->getRootPageId()); $remainingItemsCount = $GLOBALS['TYPO3_DB']->exec_SELECTcountRows('uid', 'tx_solr_indexqueue_item', 'changed > indexed AND root = ' . $this->site->getRootPageId()); $itemsIndexedCount = $totalItemsCount - $remainingItemsCount; if ($totalItemsCount > 0) { $itemsIndexedPercentage = $itemsIndexedCount * 100 / $totalItemsCount; $itemsIndexedPercentage = round($itemsIndexedPercentage, 2); } return $itemsIndexedPercentage; }
/** * Builds a map of indexing configuration names to tables to to index. * * @return array Indexing configuration to database table map */ protected function getIndexQueueConfigurationTableMap() { $indexingTableMap = array(); $solrConfiguration = \Tx_Solr_Util::getSolrConfigurationFromPageId($this->site->getRootPageId()); foreach ($solrConfiguration['index.']['queue.'] as $name => $configuration) { if (is_array($configuration)) { $name = substr($name, 0, -1); if ($solrConfiguration['index.']['queue.'][$name]) { $table = $name; if ($solrConfiguration['index.']['queue.'][$name . '.']['table']) { $table = $solrConfiguration['index.']['queue.'][$name . '.']['table']; } $indexingTableMap[$name] = $table; } } } return $indexingTableMap; }
/** * Gets $limit number of items to index for a particular $site. * * @param Tx_Solr_Site $site TYPO3 site * @param integer $limit Number of items to get from the queue * @return Tx_Solr_IndexQueue_Item[] Items to index to the given solr server */ public function getItemsToIndex(Tx_Solr_Site $site, $limit = 50) { $itemsToIndex = array(); // determine which items to index with this run $indexQueueItemRecords = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('*', 'tx_solr_indexqueue_item', 'root = ' . $site->getRootPageId() . ' AND changed > indexed' . ' AND changed <= ' . time() . ' AND errors = \'\'', '', 'indexing_priority DESC, changed DESC, uid DESC', intval($limit)); if (!empty($indexQueueItemRecords)) { // convert queued records to index queue item objects $itemsToIndex = $this->getIndexQueueItemObjectsFromRecords($indexQueueItemRecords); } return $itemsToIndex; }
/** * Gets all connection configurations for a given site. * * @param Tx_Solr_Site $site A TYPO3 site * @return array An array of Solr connection configurations for a site */ public function getConfigurationsBySite(Tx_Solr_Site $site) { $solrConfigurations = array(); $allConfigurations = $this->getAllConfigurations(); foreach ($allConfigurations as $configuration) { if ($configuration['rootPageUid'] == $site->getRootPageId()) { $solrConfigurations[] = $configuration; } } return $solrConfigurations; }
/** * Builds the SELECT part of the Index Queue initialization query. * */ protected function buildSelectStatement() { $select = 'SELECT ' . '\'' . $this->site->getRootPageId() . '\' as root, ' . '\'' . $this->type . '\' AS item_type, ' . 'uid AS item_uid, ' . '\'' . $this->indexingConfigurationName . '\' as indexing_configuration, ' . $this->getIndexingPriority() . ' AS indexing_priority, ' . $GLOBALS['TCA'][$this->type]['ctrl']['tstamp'] . ' AS changed'; return $select; }