A metric metadata class is a class that describes how a metric is described, computed and formatted. There are two types of metrics: aggregated and processed. An aggregated metric is computed in the backend datastore and aggregated in PHP when archiving period reports. Currently, only processed metrics can be defined as metric metadata classes. Support for aggregated metrics will be added at a later date. See {@link Piwik\Plugin\ProcessedMetric} and {@link Piwik\Plugin|AggregatedMetric}.
 private function deleteRowsWithNoVisit(DataTable $table)
 {
     foreach ($table->getRows() as $key => $row) {
         $nbVisits = Metric::getMetric($row, 'nb_visits');
         $nbActions = Metric::getMetric($row, 'nb_actions');
         if ($nbVisits == 0 && $nbActions == 0) {
             // case of keyword/website/campaign with a conversion for this day, but no visit, we don't show it
             $table->deleteRow($key);
         }
     }
 }
 private function getGoalsInTable(DataTable $table)
 {
     $result = array();
     foreach ($table->getRows() as $row) {
         $goals = Metric::getMetric($row, 'goals');
         if (!$goals) {
             continue;
         }
         foreach ($goals as $goalId => $goalMetrics) {
             $goalId = str_replace("idgoal=", "", $goalId);
             $result[] = $goalId;
         }
     }
     return array_unique($result);
 }
 protected function getWrappedName()
 {
     return $this->wrapped instanceof Metric ? $this->wrapped->getName() : $this->wrapped;
 }
Exemple #4
0
 /**
  * Detect the column to be used for sorting
  *
  * @param DataTable $table
  * @param string|int $columnToSort  column name or column id
  * @return int
  */
 public function getPrimaryColumnToSort(DataTable $table, $columnToSort)
 {
     // we fallback to nb_visits in case columnToSort does not exist
     $columnsToCheck = array($columnToSort, 'nb_visits');
     $row = $table->getFirstRow();
     foreach ($columnsToCheck as $column) {
         $column = Metric::getActualMetricColumn($table, $column);
         if ($row->hasColumn($column)) {
             // since getActualMetricColumn() returns a default value, we need to make sure it actually has that column
             return $column;
         }
     }
     return $columnToSort;
 }