示例#1
0
 public function hasDataTableUsers(DataTable\DataTableInterface $result)
 {
     if ($result instanceof Map) {
         foreach ($result->getDataTables() as $table) {
             if ($this->hasDataTableUsers($table)) {
                 return true;
             }
         }
     }
     if (!$result->getRowsCount()) {
         return false;
     }
     $numUsers = $result->getColumn('nb_users');
     $numUsers = array_sum($numUsers);
     return !empty($numUsers);
 }
示例#2
0
 /**
  * That methods handles the fallback to version datatables to calculate those without versions.
  *
  * Unlike DevicesDetection plugin now, the UserSettings plugin did not store archives holding the os and browser data without
  * their version number. The "version-less" reports were always generated out of the "version-containing" archives .
  * For big archives (month/year) that ment that some of the data was truncated, due to the datatable entry limit.
  * To avoid that data loss / inaccuracy in the future, DevicesDetection plugin will also store archives without the version.
  * For data archived before DevicesDetection plugin was enabled, those archives do not exist, so we try to calculate
  * them here from the "version-containing" reports if possible.
  *
  * @param DataTable\DataTableInterface $dataTable
  * @param DataTable\DataTableInterface $dataTable2
  * @return DataTable\DataTableInterface
  */
 protected function mergeDataTables(DataTable\DataTableInterface $dataTable, DataTable\DataTableInterface $dataTable2)
 {
     if ($dataTable instanceof DataTable\Map) {
         $dataTables = $dataTable->getDataTables();
         foreach ($dataTables as $label => $table) {
             $versionDataTables = $dataTable2->getDataTables();
             if (!array_key_exists($label, $versionDataTables)) {
                 continue;
             }
             $newDataTable = $this->mergeDataTables($table, $versionDataTables[$label]);
             $dataTable->addTable($newDataTable, $label);
         }
     } else {
         if (!$dataTable->getRowsCount() && $dataTable2->getRowsCount()) {
             $dataTable2->filter('GroupBy', array('label', function ($label) {
                 if (preg_match("/(.+) [0-9]+(?:\\.[0-9]+)?\$/", $label, $matches)) {
                     return $matches[1];
                     // should match for browsers
                 }
                 if (strpos($label, ';')) {
                     return substr($label, 0, 3);
                     // should match for os
                 }
                 return $label;
             }));
             return $dataTable2;
         }
     }
     return $dataTable;
 }
示例#3
0
文件: UserId.php 项目: cemo/piwik
 public function hasDataTableUsers(DataTable\DataTableInterface $result)
 {
     if ($result instanceof Map) {
         foreach ($result->getDataTables() as $table) {
             if ($this->hasDataTableUsers($table)) {
                 return true;
             }
         }
     }
     if (!$result->getRowsCount()) {
         return false;
     }
     $firstRow = $result->getFirstRow();
     if ($firstRow instanceof DataTable\Row && $firstRow->hasColumn(Metrics::INDEX_NB_USERS)) {
         $metric = Metrics::INDEX_NB_USERS;
     } else {
         $metric = 'nb_users';
     }
     $numUsers = $result->getColumn($metric);
     $numUsers = array_sum($numUsers);
     return !empty($numUsers);
 }