-
Notifications
You must be signed in to change notification settings - Fork 7
/
Archiver.php
69 lines (61 loc) · 1.85 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<?php
/**
* Piwik - Open source web analytics
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
* @package IPv6Usage
*/
namespace Piwik\Plugins\IPv6Usage;
use Piwik\Common;
use Piwik\DataAccess\LogAggregator;
use Piwik\DataArray;
use Piwik\DataTable;
use Piwik\Metrics;
/**
* Archiver for IPv6Usage Plugin
*
* @see PluginsArchiver
*/
class Archiver extends \Piwik\Plugin\Archiver
{
public function aggregateDayReport()
{
$query = $this->getLogAggregator()->queryVisitsByDimension(array('location_ip_protocol'));
if($query == false) {
return;
}
$data = array(
'IPv6Usage_IPv4' => 0,
'IPv6Usage_IPv6' => 0,
'IPv6Usage_Teredo' => 0,
'IPv6Usage_Tun6to4' => 0
);
while ($row = $query->fetch()) {
if ($row['location_ip_protocol'] == 4) {
$data['IPv6Usage_IPv4'] = $row[Metrics::INDEX_NB_VISITS];
} elseif ($row['location_ip_protocol'] == 6) {
$data['IPv6Usage_IPv6'] = $row[Metrics::INDEX_NB_VISITS];
} elseif ($row['location_ip_protocol'] == 101) {
$data['IPv6Usage_Teredo'] = $row[Metrics::INDEX_NB_VISITS];
} elseif ($row['location_ip_protocol'] == 102) {
$data['IPv6Usage_Tun6to4'] = $row[Metrics::INDEX_NB_VISITS];
}
}
foreach ($data as $key => $value) {
$this->getProcessor()->insertNumericRecord($key, $value);
}
}
public function aggregateMultipleReports()
{
$numericToSum = array(
'IPv6Usage_IPv4',
'IPv6Usage_IPv6',
'IPv6Usage_Teredo',
'IPv6Usage_Tun6to4'
);
$this->getProcessor()->aggregateNumericMetrics($numericToSum, 'sum');
}
}