PDF rausgenommen
This commit is contained in:
160
msd2/tracking/piwik/plugins/DBStats/Reports/Base.php
Normal file
160
msd2/tracking/piwik/plugins/DBStats/Reports/Base.php
Normal file
@ -0,0 +1,160 @@
|
||||
<?php
|
||||
/**
|
||||
* Piwik - free/libre analytics platform
|
||||
*
|
||||
* @link http://piwik.org
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
|
||||
*
|
||||
*/
|
||||
namespace Piwik\Plugins\DBStats\Reports;
|
||||
|
||||
use Piwik\Metrics\Formatter;
|
||||
use Piwik\Option;
|
||||
use Piwik\Piwik;
|
||||
use Piwik\Plugin\ViewDataTable;
|
||||
use Piwik\Plugins\CoreVisualizations\Visualizations\Graph;
|
||||
use Piwik\Plugins\CoreVisualizations\Visualizations\HtmlTable;
|
||||
use Piwik\Plugins\DBStats\DBStats;
|
||||
|
||||
abstract class Base extends \Piwik\Plugin\Report
|
||||
{
|
||||
public function isEnabled()
|
||||
{
|
||||
return Piwik::hasUserSuperUserAccess();
|
||||
}
|
||||
|
||||
public function configureReportMetadata(&$availableReports, $info)
|
||||
{
|
||||
// DBStats is not supposed to appear in report metadata
|
||||
}
|
||||
|
||||
protected function addBaseDisplayProperties(ViewDataTable $view)
|
||||
{
|
||||
$view->requestConfig->filter_sort_column = 'label';
|
||||
$view->requestConfig->filter_sort_order = 'desc';
|
||||
$view->requestConfig->filter_limit = 25;
|
||||
|
||||
$view->config->show_exclude_low_population = false;
|
||||
$view->config->show_table_all_columns = false;
|
||||
$view->config->show_tag_cloud = false;
|
||||
$view->config->show_search = false;
|
||||
|
||||
if ($view->isViewDataTableId(HtmlTable::ID)) {
|
||||
$view->config->keep_summary_row = true;
|
||||
$view->config->disable_row_evolution = true;
|
||||
$view->config->highlight_summary_row = true;
|
||||
}
|
||||
|
||||
if ($view->isViewDataTableId(Graph::ID)) {
|
||||
$view->config->show_series_picker = false;
|
||||
}
|
||||
|
||||
$view->config->addTranslations(array(
|
||||
'label' => Piwik::translate('DBStats_Table'),
|
||||
'year' => Piwik::translate('Intl_PeriodYear'),
|
||||
'data_size' => Piwik::translate('DBStats_DataSize'),
|
||||
'index_size' => Piwik::translate('DBStats_IndexSize'),
|
||||
'total_size' => Piwik::translate('DBStats_TotalSize'),
|
||||
'row_count' => Piwik::translate('DBStats_RowCount'),
|
||||
'percent_total' => '% ' . Piwik::translate('DBStats_DBSize'),
|
||||
'estimated_size' => Piwik::translate('DBStats_EstimatedSize')
|
||||
));
|
||||
}
|
||||
|
||||
protected function addPresentationFilters(ViewDataTable $view, $addTotalSizeColumn = true, $addPercentColumn = false,
|
||||
$sizeColumns = array('data_size', 'index_size'))
|
||||
{
|
||||
// add total_size column
|
||||
if ($addTotalSizeColumn) {
|
||||
$getTotalTableSize = function ($dataSize, $indexSize) {
|
||||
return $dataSize + $indexSize;
|
||||
};
|
||||
|
||||
$view->config->filters[] = array('ColumnCallbackAddColumn',
|
||||
array(array('data_size', 'index_size'), 'total_size', $getTotalTableSize), $isPriority = true);
|
||||
|
||||
$sizeColumns[] = 'total_size';
|
||||
}
|
||||
|
||||
$runPrettySizeFilterBeforeGeneric = false;
|
||||
|
||||
if ($view->isViewDataTableId(HtmlTable::ID)) {
|
||||
|
||||
// add summary row only if displaying a table
|
||||
$view->config->filters[] = array('AddSummaryRow', Piwik::translate('General_Total'));
|
||||
|
||||
// add percentage column if desired
|
||||
if ($addPercentColumn
|
||||
&& $addTotalSizeColumn
|
||||
) {
|
||||
$view->config->filters[] = array(
|
||||
'ColumnCallbackAddColumnPercentage',
|
||||
array('percent_total', 'total_size', 'total_size', $quotientPrecision = 0,
|
||||
$shouldSkipRows = false, $getDivisorFromSummaryRow = true),
|
||||
$isPriority = false
|
||||
);
|
||||
|
||||
$view->requestConfig->filter_sort_column = 'percent_total';
|
||||
}
|
||||
|
||||
} else if ($view->isViewDataTableId(Graph::ID)) {
|
||||
if ($addTotalSizeColumn) {
|
||||
$view->config->columns_to_display = array('label', 'total_size');
|
||||
|
||||
// when displaying a graph, we force sizes to be shown as the same unit so axis labels
|
||||
// will be readable. NOTE: The unit should depend on the smallest value of the data table,
|
||||
// however there's no way to know this information, short of creating a custom filter. For
|
||||
// now, just assume KB.
|
||||
$fixedMemoryUnit = 'K';
|
||||
$view->config->y_axis_unit = ' K';
|
||||
$view->requestConfig->filter_sort_column = 'total_size';
|
||||
$view->requestConfig->filter_sort_order = 'desc';
|
||||
} else {
|
||||
$view->config->columns_to_display = array('label', 'row_count');
|
||||
$view->config->y_axis_unit = ' ' . Piwik::translate('General_Rows');
|
||||
|
||||
$view->requestConfig->filter_sort_column = 'row_count';
|
||||
$view->requestConfig->filter_sort_order = 'desc';
|
||||
}
|
||||
$view->config->selectable_rows = array();
|
||||
}
|
||||
|
||||
$formatter = new Formatter();
|
||||
|
||||
$getPrettySize = array($formatter, 'getPrettySizeFromBytes');
|
||||
$params = !isset($fixedMemoryUnit) ? array() : array($fixedMemoryUnit);
|
||||
|
||||
$view->config->filters[] = function ($dataTable) use ($sizeColumns, $getPrettySize, $params) {
|
||||
$dataTable->filter('ColumnCallbackReplace', array($sizeColumns, $getPrettySize, $params));
|
||||
};
|
||||
|
||||
// jqPlot will display as, well, ' ', so don't replace the spaces when rendering as a graph
|
||||
if ($view->isViewDataTableId(HtmlTable::ID)) {
|
||||
$replaceSpaces = function ($value) {
|
||||
return str_replace(' ', ' ', $value);
|
||||
};
|
||||
|
||||
$view->config->filters[] = array('ColumnCallbackReplace', array($sizeColumns, $replaceSpaces));
|
||||
}
|
||||
|
||||
$getPrettyNumber = array($formatter, 'getPrettyNumber');
|
||||
$view->config->filters[] = array('ColumnCallbackReplace', array('row_count', $getPrettyNumber));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the footer message for the Individual...Summary reports.
|
||||
*/
|
||||
protected function setIndividualSummaryFooterMessage(ViewDataTable $view)
|
||||
{
|
||||
$lastGenerated = self::getDateOfLastCachingRun();
|
||||
if ($lastGenerated !== false) {
|
||||
$view->config->show_footer_message = Piwik::translate('Mobile_LastUpdated', $lastGenerated);
|
||||
}
|
||||
}
|
||||
|
||||
/** Returns the date when the cacheDataByArchiveNameReports was last run. */
|
||||
private static function getDateOfLastCachingRun()
|
||||
{
|
||||
return Option::get(DBStats::TIME_OF_LAST_TASK_RUN_OPTION);
|
||||
}
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
<?php
|
||||
/**
|
||||
* Piwik - free/libre analytics platform
|
||||
*
|
||||
* @link http://piwik.org
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
|
||||
*
|
||||
*/
|
||||
namespace Piwik\Plugins\DBStats\Reports;
|
||||
|
||||
use Piwik\Piwik;
|
||||
use Piwik\Plugin\ViewDataTable;
|
||||
use Piwik\Plugins\CoreVisualizations\Visualizations\Graph;
|
||||
|
||||
/**
|
||||
* Shows a datatable that displays the amount of space each 'admin' table takes
|
||||
* up in the MySQL database.
|
||||
*
|
||||
* An 'admin' table is a table that is not central to analytics functionality.
|
||||
* So any table that isn't an archive table or a log table is an 'admin' table.
|
||||
*/
|
||||
class GetAdminDataSummary extends Base
|
||||
{
|
||||
|
||||
protected function init()
|
||||
{
|
||||
$this->name = Piwik::translate('DBStats_OtherTables');
|
||||
}
|
||||
|
||||
public function configureView(ViewDataTable $view)
|
||||
{
|
||||
$this->addBaseDisplayProperties($view);
|
||||
$this->addPresentationFilters($view);
|
||||
|
||||
$view->requestConfig->filter_sort_order = 'asc';
|
||||
$view->config->show_offset_information = false;
|
||||
$view->config->show_pagination_control = false;
|
||||
}
|
||||
}
|
@ -0,0 +1,62 @@
|
||||
<?php
|
||||
/**
|
||||
* Piwik - free/libre analytics platform
|
||||
*
|
||||
* @link http://piwik.org
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
|
||||
*
|
||||
*/
|
||||
namespace Piwik\Plugins\DBStats\Reports;
|
||||
|
||||
use Piwik\Piwik;
|
||||
use Piwik\Plugin\ViewDataTable;
|
||||
use Piwik\Plugins\CoreVisualizations\Visualizations\Graph;
|
||||
use Piwik\Plugins\CoreVisualizations\Visualizations\JqplotGraph\Pie;
|
||||
|
||||
/**
|
||||
* Shows a datatable that displays how much space the tracker tables, numeric
|
||||
* archive tables, report tables and other tables take up in the MySQL database.
|
||||
*/
|
||||
class GetDatabaseUsageSummary extends Base
|
||||
{
|
||||
|
||||
protected function init()
|
||||
{
|
||||
$this->name = Piwik::translate('General_Overview');
|
||||
}
|
||||
|
||||
public function getDefaultTypeViewDataTable()
|
||||
{
|
||||
return Pie::ID;
|
||||
}
|
||||
|
||||
public function configureView(ViewDataTable $view)
|
||||
{
|
||||
$this->addBaseDisplayProperties($view);
|
||||
$this->addPresentationFilters($view, $addTotalSizeColumn = true, $addPercentColumn = true);
|
||||
|
||||
$view->config->show_offset_information = false;
|
||||
$view->config->show_pagination_control = false;
|
||||
|
||||
if ($view->isViewDataTableId(Graph::ID)) {
|
||||
$view->config->show_all_ticks = true;
|
||||
}
|
||||
|
||||
// translate the labels themselves
|
||||
$valueToTranslationStr = array(
|
||||
'tracker_data' => 'DBStats_TrackerTables',
|
||||
'report_data' => 'DBStats_ReportTables',
|
||||
'metric_data' => 'DBStats_MetricTables',
|
||||
'other_data' => 'DBStats_OtherTables'
|
||||
);
|
||||
|
||||
$translateSummaryLabel = function ($value) use ($valueToTranslationStr) {
|
||||
return isset($valueToTranslationStr[$value])
|
||||
? Piwik::translate($valueToTranslationStr[$value])
|
||||
: $value;
|
||||
};
|
||||
|
||||
$view->config->filters[] = array('ColumnCallbackReplace', array('label', $translateSummaryLabel), $isPriority = true);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
<?php
|
||||
/**
|
||||
* Piwik - free/libre analytics platform
|
||||
*
|
||||
* @link http://piwik.org
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
|
||||
*
|
||||
*/
|
||||
namespace Piwik\Plugins\DBStats\Reports;
|
||||
|
||||
use Piwik\Piwik;
|
||||
use Piwik\Plugin\ViewDataTable;
|
||||
use Piwik\Plugins\CoreVisualizations\Visualizations\Graph;
|
||||
use Piwik\Plugins\CoreVisualizations\Visualizations\HtmlTable;
|
||||
|
||||
/**
|
||||
* Shows a datatable that displays how many occurrences there are of each individual
|
||||
* metric type stored in the MySQL database.
|
||||
*
|
||||
* Goal metrics, metrics of the format .*_[0-9]+ and 'done...' metrics are grouped together.
|
||||
*/
|
||||
class GetIndividualMetricsSummary extends Base
|
||||
{
|
||||
|
||||
protected function init()
|
||||
{
|
||||
$this->name = Piwik::translate('General_Metrics');
|
||||
}
|
||||
|
||||
public function configureView(ViewDataTable $view)
|
||||
{
|
||||
$this->addBaseDisplayProperties($view);
|
||||
$this->addPresentationFilters($view, $addTotalSizeColumn = false, $addPercentColumn = false,
|
||||
$sizeColumns = array('estimated_size'));
|
||||
|
||||
$view->requestConfig->filter_sort_order = 'asc';
|
||||
$view->config->addTranslation('label', Piwik::translate('General_Metric'));
|
||||
|
||||
$this->setIndividualSummaryFooterMessage($view);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
<?php
|
||||
/**
|
||||
* Piwik - free/libre analytics platform
|
||||
*
|
||||
* @link http://piwik.org
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
|
||||
*
|
||||
*/
|
||||
namespace Piwik\Plugins\DBStats\Reports;
|
||||
|
||||
use Piwik\Piwik;
|
||||
use Piwik\Plugin\ViewDataTable;
|
||||
use Piwik\Plugins\CoreVisualizations\Visualizations\Graph;
|
||||
use Piwik\Plugins\CoreVisualizations\Visualizations\HtmlTable;
|
||||
|
||||
/**
|
||||
* Shows a datatable that displays how many occurrences there are of each individual
|
||||
* report type stored in the MySQL database.
|
||||
*
|
||||
* Goal reports and reports of the format: .*_[0-9]+ are grouped together.
|
||||
*/
|
||||
class GetIndividualReportsSummary extends Base
|
||||
{
|
||||
|
||||
protected function init()
|
||||
{
|
||||
$this->name = Piwik::translate('General_Reports');
|
||||
}
|
||||
|
||||
public function configureView(ViewDataTable $view)
|
||||
{
|
||||
$this->addBaseDisplayProperties($view);
|
||||
$this->addPresentationFilters($view, $addTotalSizeColumn = false, $addPercentColumn = false,
|
||||
$sizeColumns = array('estimated_size'));
|
||||
|
||||
$view->requestConfig->filter_sort_order = 'asc';
|
||||
$view->config->addTranslation('label', Piwik::translate('General_Report'));
|
||||
|
||||
// this report table has some extra columns that shouldn't be shown
|
||||
if ($view->isViewDataTableId(HtmlTable::ID)) {
|
||||
$view->config->columns_to_display = array('label', 'row_count', 'estimated_size');
|
||||
}
|
||||
|
||||
$this->setIndividualSummaryFooterMessage($view);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
<?php
|
||||
/**
|
||||
* Piwik - free/libre analytics platform
|
||||
*
|
||||
* @link http://piwik.org
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
|
||||
*
|
||||
*/
|
||||
namespace Piwik\Plugins\DBStats\Reports;
|
||||
|
||||
use Piwik\Piwik;
|
||||
use Piwik\Plugin\ViewDataTable;
|
||||
use Piwik\Plugins\CoreVisualizations\Visualizations\Graph;
|
||||
use Piwik\Plugin\ReportsProvider;
|
||||
|
||||
/**
|
||||
* Shows a datatable that displays the amount of space each numeric archive table
|
||||
* takes up in the MySQL database.
|
||||
*/
|
||||
class GetMetricDataSummary extends Base
|
||||
{
|
||||
protected function init()
|
||||
{
|
||||
$this->name = Piwik::translate('DBStats_MetricTables');
|
||||
}
|
||||
|
||||
public function configureView(ViewDataTable $view)
|
||||
{
|
||||
$this->addBaseDisplayProperties($view);
|
||||
$this->addPresentationFilters($view);
|
||||
|
||||
$view->config->title = $this->name;
|
||||
}
|
||||
|
||||
public function getRelatedReports()
|
||||
{
|
||||
return array(
|
||||
ReportsProvider::factory('DBStats', 'getMetricDataSummaryByYear'),
|
||||
);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
<?php
|
||||
/**
|
||||
* Piwik - free/libre analytics platform
|
||||
*
|
||||
* @link http://piwik.org
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
|
||||
*
|
||||
*/
|
||||
namespace Piwik\Plugins\DBStats\Reports;
|
||||
|
||||
use Piwik\Piwik;
|
||||
use Piwik\Plugin\ViewDataTable;
|
||||
use Piwik\Plugins\CoreVisualizations\Visualizations\Graph;
|
||||
use Piwik\Plugin\ReportsProvider;
|
||||
|
||||
/**
|
||||
* Shows a datatable that displays the amount of space each numeric archive table
|
||||
* takes up in the MySQL database, for each year of numeric data.
|
||||
*/
|
||||
class GetMetricDataSummaryByYear extends Base
|
||||
{
|
||||
protected function init()
|
||||
{
|
||||
$this->name = Piwik::translate('DBStats_MetricDataByYear');
|
||||
}
|
||||
|
||||
public function configureView(ViewDataTable $view)
|
||||
{
|
||||
$this->addBaseDisplayProperties($view);
|
||||
$this->addPresentationFilters($view);
|
||||
|
||||
$view->config->title = $this->name;
|
||||
$view->config->addTranslation('label', Piwik::translate('Intl_PeriodYear'));
|
||||
}
|
||||
|
||||
public function getRelatedReports()
|
||||
{
|
||||
return array(
|
||||
ReportsProvider::factory('DBStats', 'getMetricDataSummary'),
|
||||
);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
<?php
|
||||
/**
|
||||
* Piwik - free/libre analytics platform
|
||||
*
|
||||
* @link http://piwik.org
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
|
||||
*
|
||||
*/
|
||||
namespace Piwik\Plugins\DBStats\Reports;
|
||||
|
||||
use Piwik\Piwik;
|
||||
use Piwik\Plugin\ViewDataTable;
|
||||
use Piwik\Plugins\CoreVisualizations\Visualizations\Graph;
|
||||
use Piwik\Plugin\ReportsProvider;
|
||||
|
||||
/**
|
||||
* Shows a datatable that displays the amount of space each blob archive table
|
||||
* takes up in the MySQL database.
|
||||
*/
|
||||
class GetReportDataSummary extends Base
|
||||
{
|
||||
protected function init()
|
||||
{
|
||||
$this->name = Piwik::translate('DBStats_ReportTables');
|
||||
}
|
||||
|
||||
public function configureView(ViewDataTable $view)
|
||||
{
|
||||
$this->addBaseDisplayProperties($view);
|
||||
$this->addPresentationFilters($view);
|
||||
|
||||
$view->config->title = $this->name;
|
||||
}
|
||||
|
||||
public function getRelatedReports()
|
||||
{
|
||||
return array(
|
||||
ReportsProvider::factory('DBStats', 'getReportDataSummaryByYear'),
|
||||
);
|
||||
}
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
<?php
|
||||
/**
|
||||
* Piwik - free/libre analytics platform
|
||||
*
|
||||
* @link http://piwik.org
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
|
||||
*
|
||||
*/
|
||||
namespace Piwik\Plugins\DBStats\Reports;
|
||||
|
||||
use Piwik\Piwik;
|
||||
use Piwik\Plugin\ViewDataTable;
|
||||
use Piwik\Plugins\CoreVisualizations\Visualizations\Graph;
|
||||
use Piwik\Plugin\ReportsProvider;
|
||||
|
||||
/**
|
||||
* Shows a datatable that displays the amount of space each blob archive table
|
||||
* takes up in the MySQL database, for each year of blob data.
|
||||
*/
|
||||
class GetReportDataSummaryByYear extends Base
|
||||
{
|
||||
protected function init()
|
||||
{
|
||||
$this->name = Piwik::translate('DBStats_ReportDataByYear');
|
||||
}
|
||||
|
||||
public function configureView(ViewDataTable $view)
|
||||
{
|
||||
$this->addBaseDisplayProperties($view);
|
||||
$this->addPresentationFilters($view);
|
||||
|
||||
$view->config->title = $this->name;
|
||||
$view->config->addTranslation('label', Piwik::translate('Intl_PeriodYear'));
|
||||
}
|
||||
|
||||
public function getRelatedReports()
|
||||
{
|
||||
return array(
|
||||
ReportsProvider::factory('DBStats', 'getReportDataSummary'),
|
||||
);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
/**
|
||||
* Piwik - free/libre analytics platform
|
||||
*
|
||||
* @link http://piwik.org
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
|
||||
*
|
||||
*/
|
||||
namespace Piwik\Plugins\DBStats\Reports;
|
||||
|
||||
use Piwik\Piwik;
|
||||
use Piwik\Plugin\ViewDataTable;
|
||||
use Piwik\Plugins\CoreVisualizations\Visualizations\Graph;
|
||||
|
||||
/**
|
||||
* Shows a datatable that displays the amount of space each individual log table
|
||||
* takes up in the MySQL database.
|
||||
*/
|
||||
class GetTrackerDataSummary extends Base
|
||||
{
|
||||
protected function init()
|
||||
{
|
||||
$this->name = Piwik::translate('DBStats_TrackerTables');
|
||||
}
|
||||
|
||||
public function configureView(ViewDataTable $view)
|
||||
{
|
||||
$this->addBaseDisplayProperties($view);
|
||||
$this->addPresentationFilters($view);
|
||||
|
||||
$view->requestConfig->filter_sort_order = 'asc';
|
||||
$view->config->show_offset_information = false;
|
||||
$view->config->show_pagination_control = false;
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user