当前位置: 首页>>代码示例>>PHP>>正文


PHP DataTable::setMetadataValues方法代码示例

本文整理汇总了PHP中Piwik\DataTable::setMetadataValues方法的典型用法代码示例。如果您正苦于以下问题:PHP DataTable::setMetadataValues方法的具体用法?PHP DataTable::setMetadataValues怎么用?PHP DataTable::setMetadataValues使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Piwik\DataTable的用法示例。


在下文中一共展示了DataTable::setMetadataValues方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: setMetricsTotalsMetadata

 /**
  * Sets the total visits, actions & revenue for a DataTable returned by
  * $this->buildDataTable.
  *
  * @param DataTable $dataTable
  * @param array $apiMetrics Metrics info.
  * @return array Array of three values: total visits, total actions, total revenue
  */
 private function setMetricsTotalsMetadata($dataTable, $apiMetrics)
 {
     if ($dataTable instanceof DataTable\Map) {
         foreach ($dataTable->getDataTables() as $table) {
             $this->setMetricsTotalsMetadata($table, $apiMetrics);
         }
     } else {
         $totals = array();
         foreach ($apiMetrics as $label => $recordName) {
             $totals[$label] = 0;
         }
         foreach ($dataTable->getRows() as $row) {
             foreach ($apiMetrics as $totalMetadataName => $recordName) {
                 $totals[$totalMetadataName] += $row->getColumn($recordName);
             }
         }
         $dataTable->setMetadataValues($totals);
     }
 }
开发者ID:bossrabbit,项目名称:piwik,代码行数:27,代码来源:API.php

示例2: mergeChildren

 /**
  * Merges the rows of every child {@link DataTable} into a new one and
  * returns it. This function will also set the label of the merged rows
  * to the label of the {@link DataTable} they were originally from.
  *
  * The result of this function is determined by the type of DataTable
  * this instance holds. If this DataTable\Map instance holds an array
  * of DataTables, this function will transform it from:
  * 
  *     Label 0:
  *       DataTable(row1)
  *     Label 1:
  *       DataTable(row2)
  * 
  * to:
  * 
  *     DataTable(row1[label = 'Label 0'], row2[label = 'Label 1'])
  *
  * If this instance holds an array of DataTable\Maps, this function will
  * transform it from:
  * 
  *     Outer Label 0:            // the outer DataTable\Map
  *       Inner Label 0:            // one of the inner DataTable\Maps
  *         DataTable(row1)
  *       Inner Label 1:
  *         DataTable(row2)
  *     Outer Label 1:
  *       Inner Label 0:
  *         DataTable(row3)
  *       Inner Label 1:
  *         DataTable(row4)
  * 
  * to:
  * 
  *     Inner Label 0:
  *       DataTable(row1[label = 'Outer Label 0'], row3[label = 'Outer Label 1'])
  *     Inner Label 1:
  *       DataTable(row2[label = 'Outer Label 0'], row4[label = 'Outer Label 1'])
  *
  * If this instance holds an array of DataTable\Maps, the
  * metadata of the first child is used as the metadata of the result.
  *
  * This function can be used, for example, to smoosh IndexedBySite archive
  * query results into one DataTable w/ different rows differentiated by site ID.
  *
  * Note: This DataTable/Map will be destroyed and will be no longer usable after the tables have been merged into
  *       the new dataTable to reduce memory usage. Destroying all DataTables witihn the Map also seems to fix a
  *       Segmentation Fault that occurred in the AllWebsitesDashboard when having > 16k sites.
  *
  * @return DataTable|Map
  */
 public function mergeChildren()
 {
     $firstChild = reset($this->array);
     if ($firstChild instanceof Map) {
         $result = $firstChild->getEmptyClone();
         /** @var $subDataTableMap Map */
         foreach ($this->getDataTables() as $label => $subDataTableMap) {
             foreach ($subDataTableMap->getDataTables() as $innerLabel => $subTable) {
                 if (!isset($result->array[$innerLabel])) {
                     $dataTable = new DataTable();
                     $dataTable->setMetadataValues($subTable->getAllTableMetadata());
                     $result->addTable($dataTable, $innerLabel);
                 }
                 $this->copyRowsAndSetLabel($result->array[$innerLabel], $subTable, $label);
             }
         }
     } else {
         $result = new DataTable();
         foreach ($this->getDataTables() as $label => $subTable) {
             $this->copyRowsAndSetLabel($result, $subTable, $label);
             Common::destroy($subTable);
         }
         $this->array = array();
     }
     return $result;
 }
开发者ID:brienomatty,项目名称:elmsln,代码行数:77,代码来源:Map.php

示例3: makeDataTableFromSingleBlob

 /**
  * Creates a DataTable for one record from an archive data row.
  *
  * @see makeFromBlobRow
  *
  * @param array $blobRow
  * @return DataTable
  */
 private function makeDataTableFromSingleBlob($blobRow)
 {
     $recordName = reset($this->dataNames);
     if ($this->idSubtable !== null) {
         $recordName .= '_' . $this->idSubtable;
     }
     if (!empty($blobRow[$recordName])) {
         $table = DataTable::fromSerializedArray($blobRow[$recordName]);
     } else {
         $table = new DataTable();
     }
     // set table metadata
     $table->setMetadataValues(DataCollection::getDataRowMetadata($blobRow));
     if ($this->expandDataTable) {
         $table->enableRecursiveFilters();
         $this->setSubtables($table, $blobRow);
     }
     return $table;
 }
开发者ID:KiwiJuicer,项目名称:handball-dachau,代码行数:27,代码来源:DataTableFactory.php

示例4: generateInsight

 /**
  * @param array $reportMetadata
  * @param string $period
  * @param string $date
  * @param string $lastDate
  * @param string $metric
  * @param DataTable $currentReport
  * @param DataTable $lastReport
  * @param int $totalValue
  * @param int $minMoversPercent      Exclude rows who moved and the difference is not at least min percent
  *                                         visits of totalVisits. -1 excludes movers.
  * @param int $minNewPercent         Exclude rows who are new and the difference is not at least min percent
  *                                         visits of totalVisits. -1 excludes all new.
  * @param int $minDisappearedPercent Exclude rows who are disappeared and the difference is not at least min
  *                                         percent visits of totalVisits. -1 excludes all disappeared.
  * @param int $minGrowthPercentPositive    The actual growth of a row must be at least percent compared to the
  *                                         previous value (not total value)
  * @param int $minGrowthPercentNegative    The actual growth of a row must be lower percent compared to the
  *                                         previous value (not total value)
  * @param string $orderBy                  Order by absolute, relative, importance
  * @param int $limitIncreaser
  * @param int $limitDecreaser
  *
  * @return DataTable
  */
 public function generateInsight($reportMetadata, $period, $date, $lastDate, $metric, $currentReport, $lastReport, $totalValue, $minMoversPercent, $minNewPercent, $minDisappearedPercent, $minGrowthPercentPositive, $minGrowthPercentNegative, $orderBy, $limitIncreaser, $limitDecreaser)
 {
     $minChangeMovers = $this->getMinVisits($totalValue, $minMoversPercent);
     $minIncreaseNew = $this->getMinVisits($totalValue, $minNewPercent);
     $minDecreaseDisappeared = $this->getMinVisits($totalValue, $minDisappearedPercent);
     $dataTable = new DataTable();
     $dataTable->filter('Piwik\\Plugins\\Insights\\DataTable\\Filter\\Insight', array($currentReport, $lastReport, $metric, $considerMovers = -1 !== $minMoversPercent, $considerNew = -1 !== $minNewPercent, $considerDisappeared = -1 !== $minDisappearedPercent));
     $dataTable->filter('Piwik\\Plugins\\Insights\\DataTable\\Filter\\MinGrowth', array('growth_percent_numeric', $minGrowthPercentPositive, $minGrowthPercentNegative));
     if ($minIncreaseNew) {
         $dataTable->filter('Piwik\\Plugins\\Insights\\DataTable\\Filter\\ExcludeLowValue', array('difference', $minIncreaseNew, 'isNew'));
     }
     if ($minChangeMovers) {
         $dataTable->filter('Piwik\\Plugins\\Insights\\DataTable\\Filter\\ExcludeLowValue', array('difference', $minChangeMovers, 'isMover'));
     }
     if ($minDecreaseDisappeared) {
         $dataTable->filter('Piwik\\Plugins\\Insights\\DataTable\\Filter\\ExcludeLowValue', array('difference', $minDecreaseDisappeared, 'isDisappeared'));
     }
     $dataTable->filter('Piwik\\Plugins\\Insights\\DataTable\\Filter\\OrderBy', array($this->getOrderByColumn($orderBy), $orderBy === self::ORDER_BY_RELATIVE ? $this->getOrderByColumn(self::ORDER_BY_ABSOLUTE) : $this->getOrderByColumn(self::ORDER_BY_RELATIVE), $metric));
     $dataTable->filter('Piwik\\Plugins\\Insights\\DataTable\\Filter\\Limit', array('growth_percent_numeric', $limitIncreaser, $limitDecreaser));
     $metricName = $metric;
     if (!empty($reportMetadata['metrics'][$metric])) {
         $metricName = $reportMetadata['metrics'][$metric];
     }
     $dataTable->setMetadataValues(array('reportName' => $reportMetadata['name'], 'metricName' => $metricName, 'date' => $date, 'lastDate' => $lastDate, 'period' => $period, 'report' => $reportMetadata, 'totalValue' => $totalValue, 'orderBy' => $orderBy, 'metric' => $metric, 'minChangeMovers' => $minChangeMovers, 'minIncreaseNew' => $minIncreaseNew, 'minDecreaseDisappeared' => $minDecreaseDisappeared, 'minGrowthPercentPositive' => $minGrowthPercentPositive, 'minGrowthPercentNegative' => $minGrowthPercentNegative, 'minMoversPercent' => $minMoversPercent, 'minNewPercent' => $minNewPercent, 'minDisappearedPercent' => $minDisappearedPercent));
     return $dataTable;
 }
开发者ID:carriercomm,项目名称:piwik,代码行数:51,代码来源:InsightReport.php


注:本文中的Piwik\DataTable::setMetadataValues方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。