Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormattab <matthieu.aubry@gmail.com>2013-11-05 13:52:56 +0400
committermattab <matthieu.aubry@gmail.com>2013-11-05 13:52:56 +0400
commit74b81758637e420732a398813baed3c17cb2ce40 (patch)
treed9bf3b34fdf5163aaea9f7e9ee9d3450fec25118
parenta73f56303d5ee4026fd1a810ce325b0501861061 (diff)
Refs #4278 Simplifying ArchiveProcessor
-rw-r--r--core/ArchiveProcessor.php46
-rw-r--r--core/DataAccess/ArchiveWriter.php39
m---------tests/PHPUnit/UI0
3 files changed, 44 insertions, 41 deletions
diff --git a/core/ArchiveProcessor.php b/core/ArchiveProcessor.php
index 9a02d8dd49..e133ac7bbb 100644
--- a/core/ArchiveProcessor.php
+++ b/core/ArchiveProcessor.php
@@ -138,14 +138,6 @@ class ArchiveProcessor
}
/**
- * @return ArchiveWriter
- */
- public function getArchiveWriter()
- {
- return $this->archiveWriter;
- }
-
- /**
* Caches multiple numeric records in the archive for this processor's site, period
* and segment.
*
@@ -176,7 +168,7 @@ class ArchiveProcessor
public function insertNumericRecord($name, $value)
{
$value = round($value, 2);
- $this->getArchiveWriter()->insertRecord($name, $value);
+ $this->archiveWriter->insertRecord($name, $value);
}
public function getNumberOfVisits()
@@ -203,35 +195,7 @@ class ArchiveProcessor
*/
public function insertBlobRecord($name, $values)
{
- if (is_array($values)) {
- $clean = array();
- foreach ($values as $id => $value) {
- // for the parent Table we keep the name
- // for example for the Table of searchEngines we keep the name 'referrer_search_engine'
- // but for the child table of 'Google' which has the ID = 9 the name would be 'referrer_search_engine_9'
- $newName = $name;
- if ($id != 0) {
- //FIXMEA: refactor
- $newName = $name . '_' . $id;
- }
-
- $value = $this->compress($value);
- $clean[] = array($newName, $value);
- }
- $this->getArchiveWriter()->insertBulkRecords($clean);
- return;
- }
-
- $values = $this->compress($values);
- $this->getArchiveWriter()->insertRecord($name, $values);
- }
-
- protected function compress($data)
- {
- if (Db::get()->hasBlobDataType()) {
- return gzcompress($data);
- }
- return $data;
+ $this->archiveWriter->insertBlobRecord($name, $values);
}
/**
@@ -325,7 +289,7 @@ class ArchiveProcessor
$this->enrichWithUniqueVisitorsMetric($results);
foreach ($results as $name => $value) {
- $this->getArchiveWriter()->insertRecord($name, $value);
+ $this->archiveWriter->insertRecord($name, $value);
}
// if asked for only one field to sum
@@ -355,7 +319,8 @@ class ArchiveProcessor
$data = $this->archive->getDataTableExpanded($name, $idSubTable = null, $depth = null, $addMetadataSubtableId = false);
if ($data instanceof DataTable\Map) {
- foreach ($data->getDataTables() as $date => $tableToSum) {
+ // as $date => $tableToSum
+ foreach ($data->getDataTables() as $tableToSum) {
$table->addDataTable($tableToSum);
}
} else {
@@ -479,5 +444,6 @@ class ArchiveProcessor
$data = $query->fetch();
return $data[Metrics::INDEX_NB_UNIQ_VISITORS];
}
+
}
diff --git a/core/DataAccess/ArchiveWriter.php b/core/DataAccess/ArchiveWriter.php
index fdab1f08c4..c05fc596c2 100644
--- a/core/DataAccess/ArchiveWriter.php
+++ b/core/DataAccess/ArchiveWriter.php
@@ -73,6 +73,43 @@ class ArchiveWriter
$this->dateStart = $this->period->getDateStart();
}
+ /**
+ * @param string $name
+ * @param string[] $values
+ */
+ public function insertBlobRecord($name, $values)
+ {
+ if (is_array($values)) {
+ $clean = array();
+ foreach ($values as $id => $value) {
+ // for the parent Table we keep the name
+ // for example for the Table of searchEngines we keep the name 'referrer_search_engine'
+ // but for the child table of 'Google' which has the ID = 9 the name would be 'referrer_search_engine_9'
+ $newName = $name;
+ if ($id != 0) {
+ //FIXMEA: refactor
+ $newName = $name . '_' . $id;
+ }
+
+ $value = $this->compress($value);
+ $clean[] = array($newName, $value);
+ }
+ $this->insertBulkRecords($clean);
+ return;
+ }
+
+ $values = $this->compress($values);
+ $this->insertRecord($name, $values);
+ }
+
+ static protected function compress($data)
+ {
+ if (Db::get()->hasBlobDataType()) {
+ return gzcompress($data);
+ }
+ return $data;
+ }
+
protected function getArchiveLockName()
{
$numericTable = $this->getTableNumeric();
@@ -215,7 +252,7 @@ class ArchiveWriter
return Db::releaseDbLock($lockName);
}
- public function insertBulkRecords($records)
+ protected function insertBulkRecords($records)
{
// Using standard plain INSERT if there is only one record to insert
if ($DEBUG_DO_NOT_USE_BULK_INSERT = false
diff --git a/tests/PHPUnit/UI b/tests/PHPUnit/UI
-Subproject d2d2ca8c28bf85e5f809c152c7aeefdb67daa50
+Subproject b28a0c4455261b71968ece2e4c9c6d28053b596