Esempio n. 1
0
 /**
  * @param string $name
  * @param int $idSite
  * @param string $period
  * @param string|Date $date
  * @param string $segment
  * @param bool $expanded
  * @param int|null $idSubtable
  * @return DataTable
  */
 protected function getDataTable($name, $idSite, $period, $date, $segment, $expanded = false, $idSubtable = null)
 {
     $dataTable = Archive::getDataTableFromArchive($name, $idSite, $period, $date, $segment, $expanded, $idSubtable);
     $dataTable->filter('Sort', array(Metrics::INDEX_NB_VISITS, 'desc', $naturalSort = false, $expanded));
     $dataTable->queueFilter('ReplaceColumnNames');
     return $dataTable;
 }
Esempio n. 2
0
 private function getDataTable($name, $idSite, $period, $date, $segment, $expanded, $idSubtable)
 {
     Piwik::checkUserHasViewAccess($idSite);
     $recordName = Dimensions::getRecordNameForAction($name);
     $dataTable = Archive::getDataTableFromArchive($recordName, $idSite, $period, $date, $segment, $expanded, $idSubtable);
     $this->filterDataTable($dataTable);
     return $dataTable;
 }
Esempio n. 3
0
 /**
  * @param int $idSite
  * @param string $period
  * @param Date $date
  * @param string $segment
  * @param bool $expanded
  * @param int $idSubtable
  *
  * @return DataTable|DataTable\Map
  */
 protected function getDataTable($idSite, $period, $date, $segment, $expanded, $idSubtable)
 {
     $dataTable = Archive::getDataTableFromArchive(Archiver::CUSTOM_VARIABLE_RECORD_NAME, $idSite, $period, $date, $segment, $expanded, $idSubtable);
     $dataTable->filter('Sort', array(Metrics::INDEX_NB_ACTIONS, 'desc', $naturalSort = false, $expanded));
     $dataTable->queueFilter('ReplaceColumnNames');
     $dataTable->queueFilter('ColumnDelete', 'nb_uniq_visitors');
     return $dataTable;
 }
Esempio n. 4
0
 private function getDataTable($name, $idSite, $period, $date, $segment, $expanded, $idSubtable)
 {
     Piwik::checkUserHasViewAccess($idSite);
     $recordName = Dimensions::getRecordNameForAction($name);
     $dataTable = Archive::getDataTableFromArchive($recordName, $idSite, $period, $date, $segment, $expanded, $idSubtable);
     if (empty($idSubtable)) {
         $dataTable->filter('AddSegmentValue', array(function ($label) {
             if ($label === Archiver::CONTENT_PIECE_NOT_SET) {
                 return false;
             }
             return $label;
         }));
     }
     $this->filterDataTable($dataTable);
     return $dataTable;
 }
 private function bannerStats($bannerName, $params)
 {
     $contentPiece = false;
     if (strpos($bannerName, '_') !== false) {
         list($bannerName, $contentPiece) = explode('_', $bannerName);
     }
     $segment = 'contentName==' . $bannerName;
     $recordName = Dimensions::getRecordNameForAction('getContentPieces');
     $subTable = Archive::getDataTableFromArchive($recordName, $params['idSite'], $params['period'], $params['date'], $segment, true);
     //echo '<pre>';
     $bannerTable = new DataTable();
     if (!$contentPiece) {
         foreach ($subTable->getRows() as $row) {
             $ContentPieceId = Db::fetchOne("SELECT idaction FROM piwik_log_action WHERE TYPE = 14 and name = ?", array($row->getColumn('label')));
             $bannerRow = new Row(array(Row::COLUMNS => array('Label' => $row->getColumn('label'), 'Impressions' => $row->getColumn(41), 'Interactions' => $row->getColumn(42), 'Conversion rate' => $this->interactionRate($row->getColumn(41), $row->getColumn(42))), Row::DATATABLE_ASSOCIATED => implode('_', array($bannerName, $ContentPieceId))));
             $bannerTable->addRow($bannerRow);
         }
     } else {
         $orderColumn = str_replace(' ', '_', strtolower($params['filter_sort_column']));
         $orderOrder = in_array($params['filter_sort_order'], array('asc', 'desc')) ? $params['filter_sort_order'] : 'asc';
         $orderLimit = intval($params['filter_limit']);
         $where = '';
         /*
         TODO: filter_pattern is processed by piwik in some way. The results are good with this query, but piwik does some post-processing?
         if (isset($params['filter_pattern'])) {
              $where = 'and piwik_log_action.name like "%' .  $params['filter_pattern'] . '%"';
         }
         */
         $result = Db::fetchAll("\n                    SELECT \n                        trim(substring_index(piwik_log_action.name, '|', 1)) as referrer,\n                        trim(substring_index(piwik_log_action.name, '|', -1)) as target,\n                        sum(IF(idaction_content_interaction is null, 1, 0)) as impressions, \n                        sum(IF(idaction_content_interaction is null, 0, 1)) as interactions,\n                        ((100 / sum(IF(idaction_content_interaction is null, 1, 0))) * sum(IF(idaction_content_interaction is null, 0, 1))) as conversion_rate\n                    FROM piwik_log_link_visit_action \n                    left join piwik_log_action on piwik_log_action.idaction = idaction_content_target\n                    WHERE \n                        idaction_content_name in (SELECT idaction FROM piwik_log_action WHERE name = ?)\n                    and\n                        idaction_content_piece = ?\n                    \n                    {$where}\n\n                    group by piwik_log_action.name\n                    order by {$orderColumn} {$orderOrder}\n                    limit {$orderLimit}\n            ", array($bannerName, $contentPiece));
         foreach ($result as $row) {
             $bannerRow = new Row(array(Row::COLUMNS => array('Referrer' => $row['referrer'], 'Target' => $row['target'], 'Impressions' => $row['impressions'], 'Interactions' => $row['interactions'], 'Conversion rate' => round($row['conversion_rate']) . '%')));
             $bannerTable->addRow($bannerRow);
         }
     }
     return $bannerTable;
 }
Esempio n. 6
0
 protected function getDataTable($name, $idSite, $period, $date, $segment, $expanded = false, $idSubtable = null, $secondaryDimension = false)
 {
     Piwik::checkUserHasViewAccess($idSite);
     $this->checkSecondaryDimension($name, $secondaryDimension);
     $recordName = $this->getRecordNameForAction($name, $secondaryDimension);
     $dataTable = Archive::getDataTableFromArchive($recordName, $idSite, $period, $date, $segment, $expanded, $idSubtable);
     $this->filterDataTable($dataTable);
     return $dataTable;
 }
Esempio n. 7
0
 protected function getDataTableFromArchive($name, $idSite, $period, $date, $segment, $expanded = false, $idSubtable = null, $depth = null)
 {
     $skipAggregationOfSubTables = false;
     if ($period == 'range' && empty($idSubtable) && empty($expanded) && !Request::shouldLoadFlatten()) {
         $skipAggregationOfSubTables = false;
     }
     return Archive::getDataTableFromArchive($name, $idSite, $period, $date, $segment, $expanded, $idSubtable, $skipAggregationOfSubTables, $depth);
 }
Esempio n. 8
0
 /**
  * @param string $name
  * @param int $idSite
  * @param string $period
  * @param string|Date $date
  * @param string $segment
  * @param bool $expanded
  * @param int|null $idSubtable
  * @return DataTable
  */
 protected function getDataTable($name, $idSite, $period, $date, $segment, $expanded = false, $idSubtable = null)
 {
     $dataTable = Archive::getDataTableFromArchive($name, $idSite, $period, $date, $segment, $expanded, $idSubtable);
     $dataTable->queueFilter('ReplaceColumnNames');
     return $dataTable;
 }
Esempio n. 9
0
 protected function getSiteSearchKeywordsRaw($idSite, $period, $date, $segment)
 {
     $dataTable = Archive::getDataTableFromArchive('Actions_sitesearch', $idSite, $period, $date, $segment, $expanded = false);
     return $dataTable;
 }
 /**
  * Another example method that returns a data table.
  * @param int    $idSite
  * @param string $period
  * @param string $date
  * @param bool|string $segment
  * @return DataTable
  */
 public function getNewUsers($idSite, $period, $date, $segment = false)
 {
     $dataTable = Archive::getDataTableFromArchive('ClientCertificates_GetNewUsers', $idSite, $period, $date, $segment, false);
     $dataTable->queueFilter('ReplaceColumnNames');
     $dataTable->queueFilter('ReplaceSummaryRowLabel');
     $dataTable->queueFilter(function (DataTable $table) {
         foreach ($table->getRows() as $visitRow) {
             $visitor_returning = $visitRow->getColumn('label');
             if ($visitor_returning) {
                 $visitRow->setColumn('label', 'Returning Users');
             } else {
                 $visitRow->setColumn('label', 'New Users');
             }
         }
         $rowId = $table->getRowIdFromLabel('Returning Users');
         if ($rowId !== false) {
             $table->deleteRow($rowId);
         }
     });
     return $dataTable;
 }