PDF rausgenommen
This commit is contained in:
@ -0,0 +1,107 @@
|
||||
<?php
|
||||
/**
|
||||
* Piwik - free/libre analytics platform
|
||||
*
|
||||
* @link http://piwik.org
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
|
||||
*/
|
||||
namespace Piwik\Plugins\Actions\Columns\Metrics;
|
||||
|
||||
use Piwik\DataTable;
|
||||
use Piwik\DataTable\Row;
|
||||
use Piwik\Metrics;
|
||||
use Piwik\Metrics\Formatter;
|
||||
use Piwik\Piwik;
|
||||
use Piwik\Plugin\ProcessedMetric;
|
||||
|
||||
/**
|
||||
* The average amount of time it takes to generate a page. Calculated as
|
||||
*
|
||||
* sum_time_generation / nb_hits_with_time_generation
|
||||
*
|
||||
* The above metrics are calculated during archiving. This metric is calculated before
|
||||
* serving a report.
|
||||
*/
|
||||
class AveragePageGenerationTime extends ProcessedMetric
|
||||
{
|
||||
public function getName()
|
||||
{
|
||||
return 'avg_time_generation';
|
||||
}
|
||||
|
||||
public function getTranslatedName()
|
||||
{
|
||||
return Piwik::translate('General_ColumnAverageGenerationTime');
|
||||
}
|
||||
|
||||
public function getDependentMetrics()
|
||||
{
|
||||
return array('sum_time_generation', 'nb_hits_with_time_generation');
|
||||
}
|
||||
|
||||
public function getTemporaryMetrics()
|
||||
{
|
||||
return array('sum_time_generation');
|
||||
}
|
||||
|
||||
public function compute(Row $row)
|
||||
{
|
||||
$sumGenerationTime = $this->getMetric($row, 'sum_time_generation');
|
||||
$hitsWithTimeGeneration = $this->getMetric($row, 'nb_hits_with_time_generation');
|
||||
|
||||
return Piwik::getQuotientSafe($sumGenerationTime, $hitsWithTimeGeneration, $precision = 3);
|
||||
}
|
||||
|
||||
public function format($value, Formatter $formatter)
|
||||
{
|
||||
if ($formatter instanceof Formatter\Html
|
||||
&& !$value
|
||||
) {
|
||||
return '-';
|
||||
} else {
|
||||
return $formatter->getPrettyTimeFromSeconds($value, $displayAsSentence = true);
|
||||
}
|
||||
}
|
||||
|
||||
public function beforeCompute($report, DataTable $table)
|
||||
{
|
||||
$hasTimeGeneration = array_sum($this->getMetricValues($table, 'sum_time_generation')) > 0;
|
||||
|
||||
if (!$hasTimeGeneration
|
||||
&& $table->getRowsCount() != 0
|
||||
&& !$this->hasAverageTimeGeneration($table)
|
||||
) {
|
||||
// No generation time: remove it from the API output and add it to empty_columns metadata, so that
|
||||
// the columns can also be removed from the view
|
||||
$table->filter('ColumnDelete', array(array(
|
||||
Metrics::INDEX_PAGE_SUM_TIME_GENERATION,
|
||||
Metrics::INDEX_PAGE_NB_HITS_WITH_TIME_GENERATION,
|
||||
Metrics::INDEX_PAGE_MIN_TIME_GENERATION,
|
||||
Metrics::INDEX_PAGE_MAX_TIME_GENERATION,
|
||||
'sum_time_generation',
|
||||
'nb_hits_with_time_generation',
|
||||
'min_time_generation',
|
||||
'max_time_generation'
|
||||
)));
|
||||
|
||||
if ($table instanceof DataTable) {
|
||||
$emptyColumns = $table->getMetadata(DataTable::EMPTY_COLUMNS_METADATA_NAME);
|
||||
if (!is_array($emptyColumns)) {
|
||||
$emptyColumns = array();
|
||||
}
|
||||
$emptyColumns[] = 'sum_time_generation';
|
||||
$emptyColumns[] = 'avg_time_generation';
|
||||
$emptyColumns[] = 'min_time_generation';
|
||||
$emptyColumns[] = 'max_time_generation';
|
||||
$table->setMetadata(DataTable::EMPTY_COLUMNS_METADATA_NAME, $emptyColumns);
|
||||
}
|
||||
}
|
||||
|
||||
return $hasTimeGeneration;
|
||||
}
|
||||
|
||||
private function hasAverageTimeGeneration(DataTable $table)
|
||||
{
|
||||
return $table->getFirstRow()->getColumn('avg_time_generation') !== false;
|
||||
}
|
||||
}
|
@ -0,0 +1,51 @@
|
||||
<?php
|
||||
/**
|
||||
* Piwik - free/libre analytics platform
|
||||
*
|
||||
* @link http://piwik.org
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
|
||||
*/
|
||||
namespace Piwik\Plugins\Actions\Columns\Metrics;
|
||||
|
||||
use Piwik\DataTable\Row;
|
||||
use Piwik\Metrics\Formatter;
|
||||
use Piwik\Piwik;
|
||||
use Piwik\Plugin\ProcessedMetric;
|
||||
|
||||
/**
|
||||
* The average amount of time spent on a page. Calculated as:
|
||||
*
|
||||
* sum_time_spent / nb_visits
|
||||
*
|
||||
* sum_time_spent and nb_visits are calculated by Archiver classes.
|
||||
*/
|
||||
class AverageTimeOnPage extends ProcessedMetric
|
||||
{
|
||||
public function getName()
|
||||
{
|
||||
return 'avg_time_on_page';
|
||||
}
|
||||
|
||||
public function getTranslatedName()
|
||||
{
|
||||
return Piwik::translate('General_ColumnAverageTimeOnPage');
|
||||
}
|
||||
|
||||
public function compute(Row $row)
|
||||
{
|
||||
$sumTimeSpent = $this->getMetric($row, 'sum_time_spent');
|
||||
$visits = $this->getMetric($row, 'nb_hits');
|
||||
|
||||
return Piwik::getQuotientSafe($sumTimeSpent, $visits, $precision = 0);
|
||||
}
|
||||
|
||||
public function format($value, Formatter $formatter)
|
||||
{
|
||||
return $formatter->getPrettyTimeFromSeconds($value, $timeAsSentence = false);
|
||||
}
|
||||
|
||||
public function getDependentMetrics()
|
||||
{
|
||||
return array('sum_time_spent', 'nb_hits');
|
||||
}
|
||||
}
|
@ -0,0 +1,51 @@
|
||||
<?php
|
||||
/**
|
||||
* Piwik - free/libre analytics platform
|
||||
*
|
||||
* @link http://piwik.org
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
|
||||
*/
|
||||
namespace Piwik\Plugins\Actions\Columns\Metrics;
|
||||
|
||||
use Piwik\DataTable\Row;
|
||||
use Piwik\Metrics\Formatter;
|
||||
use Piwik\Piwik;
|
||||
use Piwik\Plugin\ProcessedMetric;
|
||||
|
||||
/**
|
||||
* The bounce rate for individual pages. Calculated as:
|
||||
*
|
||||
* entry_bounce_count (single page visits on this page) / entry_nb_visits (all visits that started on this page)
|
||||
*
|
||||
* entry_bounce_count & entry_nb_visits are calculated by the Actions archiver.
|
||||
*/
|
||||
class BounceRate extends ProcessedMetric
|
||||
{
|
||||
public function getName()
|
||||
{
|
||||
return 'bounce_rate';
|
||||
}
|
||||
|
||||
public function getTranslatedName()
|
||||
{
|
||||
return Piwik::translate('General_ColumnBounceRate');
|
||||
}
|
||||
|
||||
public function compute(Row $row)
|
||||
{
|
||||
$entryBounceCount = $this->getMetric($row, 'entry_bounce_count');
|
||||
$entryVisits = $this->getMetric($row, 'entry_nb_visits');
|
||||
|
||||
return Piwik::getQuotientSafe($entryBounceCount, $entryVisits, $precision = 2);
|
||||
}
|
||||
|
||||
public function format($value, Formatter $formatter)
|
||||
{
|
||||
return $formatter->getPrettyPercentFromQuotient($value);
|
||||
}
|
||||
|
||||
public function getDependentMetrics()
|
||||
{
|
||||
return array('entry_bounce_count', 'entry_nb_visits');
|
||||
}
|
||||
}
|
@ -0,0 +1,51 @@
|
||||
<?php
|
||||
/**
|
||||
* Piwik - free/libre analytics platform
|
||||
*
|
||||
* @link http://piwik.org
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
|
||||
*/
|
||||
namespace Piwik\Plugins\Actions\Columns\Metrics;
|
||||
|
||||
use Piwik\DataTable\Row;
|
||||
use Piwik\Metrics\Formatter;
|
||||
use Piwik\Piwik;
|
||||
use Piwik\Plugin\ProcessedMetric;
|
||||
|
||||
/**
|
||||
* Percent of visits that finished on this page. Calculated as:
|
||||
*
|
||||
* exit_nb_visits / nb_visits
|
||||
*
|
||||
* exit_nb_visits & nb_visits are calculated by the Actions archiver.
|
||||
*/
|
||||
class ExitRate extends ProcessedMetric
|
||||
{
|
||||
public function getName()
|
||||
{
|
||||
return 'exit_rate';
|
||||
}
|
||||
|
||||
public function getTranslatedName()
|
||||
{
|
||||
return Piwik::translate('General_ColumnExitRate');
|
||||
}
|
||||
|
||||
public function compute(Row $row)
|
||||
{
|
||||
$exitVisits = $this->getMetric($row, 'exit_nb_visits');
|
||||
$visits = $this->getMetric($row, 'nb_visits');
|
||||
|
||||
return Piwik::getQuotientSafe($exitVisits, $visits, $precision = 2);
|
||||
}
|
||||
|
||||
public function format($value, Formatter $formatter)
|
||||
{
|
||||
return $formatter->getPrettyPercentFromQuotient($value);
|
||||
}
|
||||
|
||||
public function getDependentMetrics()
|
||||
{
|
||||
return array('exit_nb_visits', 'nb_visits');
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user