This repository has been archived by the owner on Jul 20, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Archiver.php
54 lines (46 loc) · 1.69 KB
/
Archiver.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
/**
* Piwik PRO - Premium functionality and enterprise-level support for Piwik Analytics
*
* @link http://piwik.pro
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
namespace Piwik\Plugins\Organisations;
use Piwik\Metrics;
class Archiver extends \Piwik\Plugin\Archiver
{
const ORGANISATIONS_RECORD_NAME = 'Organisations_all';
const ORGANISATION_FIELD = "organisation";
/**
* Aggregates reports for a single day
*
* @throws \Exception
*/
public function aggregateDayReport()
{
$metrics = $this->getLogAggregator()->getMetricsFromVisitByDimension(self::ORGANISATION_FIELD);
$query = $this->getLogAggregator()->queryConversionsByDimension(array(self::ORGANISATION_FIELD));
if ($query === false) {
return;
}
while ($conversionRow = $query->fetch()) {
$metrics->sumMetricsGoals($conversionRow['organisation'], $conversionRow);
}
$metrics->enrichMetricsWithConversions();
$report = $metrics->asDataTable()->getSerialized($this->maximumRows, null, Metrics::INDEX_NB_VISITS);
$this->getProcessor()->insertBlobRecord(self::ORGANISATIONS_RECORD_NAME, $report);
}
public function aggregateMultipleReports()
{
$columnsAggregationOperation = null;
$this->getProcessor()->aggregateDataTableRecords(
array(self::ORGANISATIONS_RECORD_NAME),
$this->maximumRows,
$maximumRowsInSubDataTable = null,
$columnToSortByBeforeTruncation = null,
$columnsAggregationOperation,
$columnsToRenameAfterAggregation = null,
$countRowsRecursive = array()
);
}
}