diff options
author | diosmosis <benaka@piwik.pro> | 2014-11-14 07:46:17 +0300 |
---|---|---|
committer | diosmosis <benaka@piwik.pro> | 2014-11-14 07:46:17 +0300 |
commit | 05c4b313cf29bec72bb6cd8ed10142b84b39a4c6 (patch) | |
tree | c925d37a080f805a72c25353f2114bccf32034ab /plugins/Contents/Columns | |
parent | 545d316d4dad434edfe5048807bfbe686f856259 (diff) |
Move all Metrics to Columns folder.
Diffstat (limited to 'plugins/Contents/Columns')
-rw-r--r-- | plugins/Contents/Columns/Metrics/InteractionRate.php | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/plugins/Contents/Columns/Metrics/InteractionRate.php b/plugins/Contents/Columns/Metrics/InteractionRate.php new file mode 100644 index 0000000000..64485fe0e6 --- /dev/null +++ b/plugins/Contents/Columns/Metrics/InteractionRate.php @@ -0,0 +1,52 @@ +<?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\Contents\Columns\Metrics; + +use Piwik\DataTable\Row; +use Piwik\Metrics\Formatter; +use Piwik\Piwik; +use Piwik\Plugin\ProcessedMetric; + +/** + * The content interaction rate. Calculated as: + * + * nb_interactions / nb_impressions + * + * nb_interactions & nb_impressions are calculated by the Contents archiver. + */ +class InteractionRate extends ProcessedMetric +{ + public function getName() + { + return 'interaction_rate'; + } + + public function getTranslatedName() + { + return Piwik::translate('Contents_InteractionRate'); + } + + public function compute(Row $row) + { + $interactions = $this->getMetric($row, 'nb_interactions'); + $impressions = $this->getMetric($row, 'nb_impressions'); + + return Piwik::getQuotientSafe($interactions, $impressions, $precision = 4); + } + + public function format($value, Formatter $formatter) + { + return $formatter->getPrettyPercentFromQuotient($value); + } + + public function getDependentMetrics() + { + return array('nb_interactions', 'nb_impressions'); + } +}
\ No newline at end of file |