/** Build DataTable from array and archive it */ private function archiveDataArray($keyword, &$data) { $dataTable = new Piwik_DataTable(); foreach ($data as &$row) { $dataTable->addRow(new Piwik_SiteUsers_ExtendedDataTableRow(array(Piwik_DataTable_Row::COLUMNS => $row))); } $name = 'SiteUsers_' . $keyword; $this->archiveProcessing->insertBlobRecord($name, $dataTable->getSerialized()); destroy($dataTable); }
/** * Build DataTable from array and archive it * @return id of the datatable */ private function archiveDataArray($keyword, &$data, $addSearchTermMetaData = false, $addUrlMetaData = false) { $dataTable = new Piwik_DataTable(); foreach ($data as &$row) { $rowData = array(Piwik_DataTable_Row::COLUMNS => $row); if ($addSearchTermMetaData) { $rowData[Piwik_DataTable_Row::METADATA] = array('idSearch' => $row[$addSearchTermMetaData], 'searchTerm' => $row[self::SEARCH_TERM]); } if ($addUrlMetaData) { $rowData[Piwik_DataTable_Row::METADATA]['url'] = $row[self::URL]; } $dataTable->addRow(new Piwik_SiteSearch_ExtendedDataTableRow($rowData)); } $id = $dataTable->getId(); $name = 'SiteSearch_' . $keyword; $this->archiveProcessing->insertBlobRecord($name, $dataTable->getSerialized()); destroy($dataTable); return $id; }
/** * Records the daily stats (numeric or datatable blob) into the archive tables. * * @param Piwik_ArchiveProcessing $archiveProcessing * @return void */ protected function archiveDayRecordInDatabase($archiveProcessing) { $numericRecords = array('Referers_distinctSearchEngines' => count($this->interestBySearchEngineAndKeyword), 'Referers_distinctKeywords' => count($this->interestByKeywordAndSearchEngine), 'Referers_distinctCampaigns' => count($this->interestByCampaign), 'Referers_distinctWebsites' => count($this->interestByWebsite), 'Referers_distinctWebsitesUrls' => count($this->distinctUrls)); foreach ($numericRecords as $name => $value) { $archiveProcessing->insertNumericRecord($name, $value); } $dataTable = $archiveProcessing->getDataTableSerialized($this->interestByType); $archiveProcessing->insertBlobRecord('Referers_type', $dataTable); destroy($dataTable); $blobRecords = array('Referers_keywordBySearchEngine' => $archiveProcessing->getDataTableWithSubtablesFromArraysIndexedByLabel($this->interestBySearchEngineAndKeyword, $this->interestBySearchEngine), 'Referers_searchEngineByKeyword' => $archiveProcessing->getDataTableWithSubtablesFromArraysIndexedByLabel($this->interestByKeywordAndSearchEngine, $this->interestByKeyword), 'Referers_keywordByCampaign' => $archiveProcessing->getDataTableWithSubtablesFromArraysIndexedByLabel($this->interestByCampaignAndKeyword, $this->interestByCampaign), 'Referers_urlByWebsite' => $archiveProcessing->getDataTableWithSubtablesFromArraysIndexedByLabel($this->interestByWebsiteAndUrl, $this->interestByWebsite)); foreach ($blobRecords as $recordName => $table) { $blob = $table->getSerialized($this->maximumRowsInDataTableLevelZero, $this->maximumRowsInSubDataTable, $this->columnToSortByBeforeTruncation); $archiveProcessing->insertBlobRecord($recordName, $blob); destroy($table); } }
/** * @param Piwik_ArchiveProcessing $archiveProcessing * @return void */ protected function archiveDayRecordInDatabase($archiveProcessing) { $recordName = 'CustomVariables_valueByName'; $table = $archiveProcessing->getDataTableWithSubtablesFromArraysIndexedByLabel($this->interestByCustomVariablesAndValue, $this->interestByCustomVariables); $blob = $table->getSerialized($this->maximumRowsInDataTableLevelZero, $this->maximumRowsInSubDataTable); $archiveProcessing->insertBlobRecord($recordName, $blob); destroy($table); }