/** * @since 1.9 */ public function rebuild() { $this->reportMessage("Updating property statistics. This may take a while.\n"); $this->propertyStatisticsStore->deleteAll(); $res = $this->store->getConnection('mw.db')->select(\SMWSql3SmwIds::tableName, array('smw_id', 'smw_title'), array('smw_namespace' => SMW_NS_PROPERTY), __METHOD__); foreach ($res as $row) { $this->reportMessage('.'); $usageCount = 0; foreach ($this->store->getPropertyTables() as $propertyTable) { if ($propertyTable->isFixedPropertyTable() && $propertyTable->getFixedProperty() !== $row->smw_title) { // This table cannot store values for this property continue; } $usageCount += $this->getPropertyTableRowCount($propertyTable, $row->smw_id); } $this->propertyStatisticsStore->insertUsageCount((int) $row->smw_id, $usageCount); } $propCount = $res->numRows(); $this->store->getConnection('mw.db')->freeResult($res); $this->reportMessage("\nUpdated statistics for {$propCount} Properties.\n"); }
private function buildPropertyList($res) { $result = array(); $propertyIds = array(); foreach ($res as $row) { $propertyIds[] = (int) $row->smw_id; } $usageCounts = $this->propertyStatisticsStore->getUsageCounts($propertyIds); foreach ($res as $row) { $result[] = $this->addPropertyRowToList($row, $usageCounts); } return $result; }
private function selectPropertiesFromTable() { // the query needs to do the filtering of internal properties, else LIMIT is wrong $options = array('ORDER BY' => 'smw_sortkey'); if ($this->requestOptions->limit > 0) { $options['LIMIT'] = $this->requestOptions->limit; $options['OFFSET'] = max($this->requestOptions->offset, 0); } $conditions = array('smw_id > ' . SQLStore::FIXED_PROPERTY_ID_UPPERBOUND, 'smw_namespace' => SMW_NS_PROPERTY, 'smw_iw' => '', 'smw_subobject' => ''); $conditions['usage_count'] = 0; $idTable = $this->store->getObjectIds()->getIdTable(); $res = $this->store->getConnection('mw.db')->select(array($idTable, $this->propertyStatisticsStore->getStatisticsTable()), array('smw_title', 'usage_count'), $conditions, __METHOD__, $options, array($idTable => array('INNER JOIN', array('smw_id=p_id')))); return $res; }
/** * @since 2.2 * * @return number */ public function getImproperValueForCount() { return $this->propertyStatisticsStore->getUsageCount($this->store->getObjectIds()->getSMWPropertyID(new DIProperty('_ERRP'))); }