Exemple #1
0
 public function test_missingColumnValues_shouldAppearLast_afterSortDesc()
 {
     $table = new Piwik_DataTable();
     $table->addRowsFromArray(array(array(Piwik_DataTable_Row::COLUMNS => array('label' => 'nintendo', 'count' => 1)), array(Piwik_DataTable_Row::COLUMNS => array('label' => 'ask', 'count' => 2)), array(Piwik_DataTable_Row::COLUMNS => array('label' => 'amazing')), Piwik_DataTable::ID_SUMMARY_ROW => array(Piwik_DataTable_Row::COLUMNS => array('label' => 'summary', 'count' => 10))));
     $filter = new Piwik_DataTable_Filter_Sort($table, 'count', 'desc');
     $expectedOrder = array('ask', 'nintendo', 'amazing', 'summary');
     $this->assertEqual($table->getColumn('label'), $expectedOrder);
 }
Exemple #2
0
 /**
  * Utility function that adds a visit percent column to a data table,
  * regardless of whether the data table is an data table array or just
  * a data table.
  *
  * @param Piwik_DataTable $dataTable The data table to modify.
  */
 private static function addVisitsPercentColumn($dataTable)
 {
     if ($dataTable instanceof Piwik_DataTable_Array) {
         foreach ($dataTable->getArray() as $table) {
             self::addVisitsPercentColumn($table);
         }
     } else {
         $totalVisits = array_sum($dataTable->getColumn(Piwik_Archive::INDEX_NB_VISITS));
         $dataTable->queueFilter('ColumnCallbackAddColumnPercentage', array('nb_visits_percentage', 'nb_visits', $totalVisits));
     }
 }