blob: 2e9accd741cf56091dbd211fe3ee60df35052c7c (
plain)
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
|
<?php
/**
* Piwik - free/libre analytics platform
*
* @link https://matomo.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
*/
namespace Piwik\Plugins\CoreHome\Columns;
use Piwik\Date;
use Piwik\Metrics\Formatter;
use Piwik\Plugin\Dimension\ActionDimension;
use Piwik\Tracker\Action;
use Piwik\Tracker\Request;
use Piwik\Tracker\Visitor;
require_once PIWIK_INCLUDE_PATH . '/plugins/VisitTime/functions.php';
class ServerTime extends ActionDimension
{
protected $columnName = 'server_time';
protected $columnType = 'DATETIME NOT NULL';
protected $segmentName = 'actionServerHour';
protected $sqlSegment = 'HOUR(log_link_visit_action.server_time)';
protected $nameSingular = 'VisitTime_ColumnServerHour';
protected $type = self::TYPE_DATETIME;
public function __construct()
{
$this->suggestedValuesCallback = function ($idSite, $maxValuesToReturn) {
return range(0, min(23, $maxValuesToReturn));
};
}
public function formatValue($value, $idSite, Formatter $formatter)
{
return \Piwik\Plugins\VisitTime\getTimeLabel($value);
}
public function install()
{
$changes = parent::install();
$changes['log_link_visit_action'][] = "ADD INDEX index_idsite_servertime ( idsite, server_time )";
return $changes;
}
public function onNewAction(Request $request, Visitor $visitor, Action $action)
{
$timestamp = $request->getCurrentTimestamp();
return Date::getDatetimeFromTimestamp($timestamp);
}
}
|