update Piwik to version 2.16 (fixes #91)
This commit is contained in:
parent
9abe039dc8
commit
47263617c5
69 changed files with 418860 additions and 226988 deletions
1
www/analytics/plugins/DBStats/.gitignore
vendored
1
www/analytics/plugins/DBStats/.gitignore
vendored
|
|
@ -1 +0,0 @@
|
|||
tests/UI/processed-ui-screenshots
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
/**
|
||||
* Piwik - Open source web analytics
|
||||
* Piwik - free/libre analytics platform
|
||||
*
|
||||
* @link http://piwik.org
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
|
||||
|
|
@ -12,14 +12,9 @@ use Piwik\Common;
|
|||
use Piwik\DataTable;
|
||||
use Piwik\Piwik;
|
||||
|
||||
/**
|
||||
* @see plugins/DBStats/MySQLMetadataProvider.php
|
||||
*/
|
||||
require_once PIWIK_INCLUDE_PATH . '/plugins/DBStats/MySQLMetadataProvider.php';
|
||||
|
||||
/**
|
||||
* DBStats API is used to request the overall status of the Mysql tables in use by Piwik.
|
||||
*
|
||||
* @hideExceptForSuperUser
|
||||
* @method static \Piwik\Plugins\DBStats\API getInstance()
|
||||
*/
|
||||
class API extends \Piwik\Plugin\API
|
||||
|
|
@ -29,18 +24,16 @@ class API extends \Piwik\Plugin\API
|
|||
*/
|
||||
private $metadataProvider;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
protected function __construct()
|
||||
public function __construct(MySQLMetadataProvider $metadataProvider)
|
||||
{
|
||||
$this->metadataProvider = new MySQLMetadataProvider();
|
||||
$this->metadataProvider = $metadataProvider;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets some general information about this Piwik installation, including the count of
|
||||
* websites tracked, the count of users and the total space used by the database.
|
||||
*
|
||||
*
|
||||
* @return array Contains the website count, user count and total space used by the database.
|
||||
*/
|
||||
public function getGeneralInformation()
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
/**
|
||||
* Piwik - Open source web analytics
|
||||
* Piwik - free/libre analytics platform
|
||||
*
|
||||
* @link http://piwik.org
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
|
||||
|
|
@ -8,10 +8,9 @@
|
|||
*/
|
||||
namespace Piwik\Plugins\DBStats;
|
||||
|
||||
use Piwik\MetricsFormatter;
|
||||
use Piwik\Metrics\Formatter;
|
||||
use Piwik\Piwik;
|
||||
use Piwik\View;
|
||||
use Piwik\ViewDataTable\Factory;
|
||||
|
||||
/**
|
||||
*/
|
||||
|
|
@ -30,131 +29,19 @@ class Controller extends \Piwik\Plugin\ControllerAdmin
|
|||
$view = new View('@DBStats/index');
|
||||
$this->setBasicVariablesView($view);
|
||||
|
||||
$view->databaseUsageSummary = $this->getDatabaseUsageSummary(true);
|
||||
$view->trackerDataSummary = $this->getTrackerDataSummary(true);
|
||||
$view->metricDataSummary = $this->getMetricDataSummary(true);
|
||||
$view->reportDataSummary = $this->getReportDataSummary(true);
|
||||
$view->adminDataSummary = $this->getAdminDataSummary(true);
|
||||
$view->databaseUsageSummary = $this->renderReport('getDatabaseUsageSummary');
|
||||
$view->trackerDataSummary = $this->renderReport('getTrackerDataSummary');
|
||||
$view->metricDataSummary = $this->renderReport('getMetricDataSummary');
|
||||
$view->reportDataSummary = $this->renderReport('getReportDataSummary');
|
||||
$view->adminDataSummary = $this->renderReport('getAdminDataSummary');
|
||||
|
||||
list($siteCount, $userCount, $totalSpaceUsed) = API::getInstance()->getGeneralInformation();
|
||||
$view->siteCount = MetricsFormatter::getPrettyNumber($siteCount);
|
||||
$view->userCount = MetricsFormatter::getPrettyNumber($userCount);
|
||||
$view->totalSpaceUsed = MetricsFormatter::getPrettySizeFromBytes($totalSpaceUsed);
|
||||
|
||||
$formatter = new Formatter();
|
||||
$view->siteCount = $formatter->getPrettyNumber($siteCount);
|
||||
$view->userCount = $formatter->getPrettyNumber($userCount);
|
||||
$view->totalSpaceUsed = $formatter->getPrettySizeFromBytes($totalSpaceUsed);
|
||||
|
||||
return $view->render();
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDatabaseUsageSummary()
|
||||
{
|
||||
Piwik::checkUserHasSuperUserAccess();
|
||||
return $this->renderReport(__FUNCTION__);
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows a datatable that displays the amount of space each individual log table
|
||||
* takes up in the MySQL database.
|
||||
* @return string|void
|
||||
*/
|
||||
public function getTrackerDataSummary()
|
||||
{
|
||||
Piwik::checkUserHasSuperUserAccess();
|
||||
return $this->renderReport(__FUNCTION__);
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows a datatable that displays the amount of space each numeric archive table
|
||||
* takes up in the MySQL database.
|
||||
*
|
||||
* @return string|void
|
||||
*/
|
||||
public function getMetricDataSummary()
|
||||
{
|
||||
Piwik::checkUserHasSuperUserAccess();
|
||||
return $this->renderReport(__FUNCTION__);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* @return string|void
|
||||
*/
|
||||
public function getMetricDataSummaryByYear()
|
||||
{
|
||||
Piwik::checkUserHasSuperUserAccess();
|
||||
return $this->renderReport(__FUNCTION__);
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows a datatable that displays the amount of space each blob archive table
|
||||
* takes up in the MySQL database.
|
||||
*
|
||||
* @return string|void
|
||||
*/
|
||||
public function getReportDataSummary()
|
||||
{
|
||||
Piwik::checkUserHasSuperUserAccess();
|
||||
return $this->renderReport(__FUNCTION__);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* @return string|void
|
||||
*/
|
||||
public function getReportDataSummaryByYear()
|
||||
{
|
||||
Piwik::checkUserHasSuperUserAccess();
|
||||
return $this->renderReport(__FUNCTION__);
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows a datatable that displays how many occurances there are of each individual
|
||||
* report type stored in the MySQL database.
|
||||
*
|
||||
* Goal reports and reports of the format: .*_[0-9]+ are grouped together.
|
||||
*
|
||||
* @return string|void
|
||||
*/
|
||||
public function getIndividualReportsSummary()
|
||||
{
|
||||
Piwik::checkUserHasSuperUserAccess();
|
||||
return $this->renderReport(__FUNCTION__);
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows a datatable that displays how many occurances 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.
|
||||
*
|
||||
* @return string|void
|
||||
*/
|
||||
public function getIndividualMetricsSummary()
|
||||
{
|
||||
Piwik::checkUserHasSuperUserAccess();
|
||||
return $this->renderReport(__FUNCTION__);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* @return string|void
|
||||
*/
|
||||
public function getAdminDataSummary()
|
||||
{
|
||||
Piwik::checkUserHasSuperUserAccess();
|
||||
return $this->renderReport(__FUNCTION__);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
/**
|
||||
* Piwik - Open source web analytics
|
||||
* Piwik - free/libre analytics platform
|
||||
*
|
||||
* @link http://piwik.org
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
|
||||
|
|
@ -8,379 +8,35 @@
|
|||
*/
|
||||
namespace Piwik\Plugins\DBStats;
|
||||
|
||||
use Piwik\Date;
|
||||
use Piwik\Menu\MenuAdmin;
|
||||
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\CoreVisualizations\Visualizations\JqplotGraph\Pie;
|
||||
use Piwik\ScheduledTask;
|
||||
use Piwik\ScheduledTime\Weekly;
|
||||
use Piwik\ScheduledTime;
|
||||
use Piwik\Plugins\DBStats\tests\Mocks\MockDataAccess;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
class DBStats extends \Piwik\Plugin
|
||||
{
|
||||
const TIME_OF_LAST_TASK_RUN_OPTION = 'dbstats_time_of_last_cache_task_run';
|
||||
|
||||
/**
|
||||
* @see Piwik\Plugin::getListHooksRegistered
|
||||
* @see Piwik\Plugin::registerEvents
|
||||
*/
|
||||
public function getListHooksRegistered()
|
||||
public function registerEvents()
|
||||
{
|
||||
return array(
|
||||
'AssetManager.getStylesheetFiles' => 'getStylesheetFiles',
|
||||
'Menu.Admin.addItems' => 'addMenu',
|
||||
'TaskScheduler.getScheduledTasks' => 'getScheduledTasks',
|
||||
'ViewDataTable.configure' => 'configureViewDataTable',
|
||||
'ViewDataTable.getDefaultType' => 'getDefaultTypeViewDataTable',
|
||||
"TestingEnvironment.addHooks" => 'setupTestEnvironment'
|
||||
);
|
||||
}
|
||||
|
||||
function addMenu()
|
||||
{
|
||||
MenuAdmin::getInstance()->add('CoreAdminHome_MenuDiagnostic', 'DBStats_DatabaseUsage',
|
||||
array('module' => 'DBStats', 'action' => 'index'),
|
||||
Piwik::hasUserSuperUserAccess(),
|
||||
$order = 6);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets all scheduled tasks executed by this plugin.
|
||||
*/
|
||||
public function getScheduledTasks(&$tasks)
|
||||
{
|
||||
$cacheDataByArchiveNameReportsTask = new ScheduledTask(
|
||||
$this,
|
||||
'cacheDataByArchiveNameReports',
|
||||
null,
|
||||
ScheduledTime::factory('weekly'),
|
||||
ScheduledTask::LOWEST_PRIORITY
|
||||
);
|
||||
$tasks[] = $cacheDataByArchiveNameReportsTask;
|
||||
}
|
||||
|
||||
/**
|
||||
* Caches the intermediate DataTables used in the getIndividualReportsSummary and
|
||||
* getIndividualMetricsSummary reports in the option table.
|
||||
*/
|
||||
public function cacheDataByArchiveNameReports()
|
||||
{
|
||||
$api = API::getInstance();
|
||||
$api->getIndividualReportsSummary(true);
|
||||
$api->getIndividualMetricsSummary(true);
|
||||
|
||||
$now = Date::now()->getLocalized("%longYear%, %shortMonth% %day%");
|
||||
Option::set(self::TIME_OF_LAST_TASK_RUN_OPTION, $now);
|
||||
}
|
||||
|
||||
public function getStylesheetFiles(&$stylesheets)
|
||||
{
|
||||
$stylesheets[] = "plugins/DBStats/stylesheets/dbStatsTable.less";
|
||||
}
|
||||
|
||||
/** Returns the date when the cacheDataByArchiveNameReports was last run. */
|
||||
public static function getDateOfLastCachingRun()
|
||||
{
|
||||
return Option::get(self::TIME_OF_LAST_TASK_RUN_OPTION);
|
||||
}
|
||||
|
||||
public function getDefaultTypeViewDataTable(&$defaultViewTypes)
|
||||
{
|
||||
$defaultViewTypes['DBStats.getDatabaseUsageSummary'] = Pie::ID;
|
||||
$defaultViewTypes['DBStats.getTrackerDataSummary'] = HtmlTable::ID;
|
||||
$defaultViewTypes['DBStats.getMetricDataSummary'] = HtmlTable::ID;
|
||||
$defaultViewTypes['DBStats.getMetricDataSummaryByYear'] = HtmlTable::ID;
|
||||
$defaultViewTypes['DBStats.getReportDataSummary'] = HtmlTable::ID;
|
||||
$defaultViewTypes['DBStats.getReportDataSummaryByYear'] = HtmlTable::ID;
|
||||
$defaultViewTypes['DBStats.getIndividualReportsSummary'] = HtmlTable::ID;
|
||||
$defaultViewTypes['DBStats.getIndividualMetricsSummary'] = HtmlTable::ID;
|
||||
$defaultViewTypes['DBStats.getAdminDataSummary'] = HtmlTable::ID;
|
||||
}
|
||||
|
||||
public function configureViewDataTable(ViewDataTable $view)
|
||||
{
|
||||
switch ($view->requestConfig->apiMethodToRequestDataTable) {
|
||||
case 'DBStats.getDatabaseUsageSummar':
|
||||
$this->configureViewForGetDatabaseUsageSummary($view);
|
||||
break;
|
||||
case 'DBStats.getTrackerDataSummary':
|
||||
$this->configureViewForGetTrackerDataSummary($view);
|
||||
break;
|
||||
case 'DBStats.getMetricDataSummary':
|
||||
$this->configureViewForGetMetricDataSummary($view);
|
||||
break;
|
||||
case 'DBStats.getMetricDataSummaryByYear':
|
||||
$this->configureViewForGetMetricDataSummaryByYear($view);
|
||||
break;
|
||||
case 'DBStats.getReportDataSummary':
|
||||
$this->configureViewForGetReportDataSummary($view);
|
||||
break;
|
||||
case 'DBStats.getReportDataSummaryByYear':
|
||||
$this->configureViewForGetReportDataSummaryByYear($view);
|
||||
break;
|
||||
case 'DBStats.getIndividualReportsSummary':
|
||||
$this->configureViewForGetIndividualReportsSummary($view);
|
||||
break;
|
||||
case 'DBStats.getIndividualMetricsSummary':
|
||||
$this->configureViewForGetIndividualMetricsSummary($view);
|
||||
break;
|
||||
case 'DBStats.getAdminDataSummary':
|
||||
$this->configureViewForGetAdminDataSummary($view);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private function configureViewForGetDatabaseUsageSummary(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);
|
||||
}
|
||||
|
||||
private function configureViewForGetTrackerDataSummary(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;
|
||||
}
|
||||
|
||||
private function configureViewForGetMetricDataSummary(ViewDataTable $view)
|
||||
{
|
||||
$this->addBaseDisplayProperties($view);
|
||||
$this->addPresentationFilters($view);
|
||||
|
||||
$view->config->title = Piwik::translate('DBStats_MetricTables');
|
||||
$view->config->addRelatedReports(array(
|
||||
'DBStats.getMetricDataSummaryByYear' => Piwik::translate('DBStats_MetricDataByYear')
|
||||
));
|
||||
}
|
||||
|
||||
private function configureViewForGetMetricDataSummaryByYear(ViewDataTable $view)
|
||||
{
|
||||
$this->addBaseDisplayProperties($view);
|
||||
$this->addPresentationFilters($view);
|
||||
|
||||
$view->config->title = Piwik::translate('DBStats_MetricDataByYear');
|
||||
$view->config->addTranslation('label', Piwik::translate('CoreHome_PeriodYear'));
|
||||
$view->config->addRelatedReports(array(
|
||||
'DBStats.getMetricDataSummary' => Piwik::translate('DBStats_MetricTables')
|
||||
));
|
||||
}
|
||||
|
||||
private function configureViewForGetReportDataSummary(ViewDataTable $view)
|
||||
{
|
||||
$this->addBaseDisplayProperties($view);
|
||||
$this->addPresentationFilters($view);
|
||||
|
||||
$view->config->title = Piwik::translate('DBStats_ReportTables');
|
||||
$view->config->addRelatedReports(array(
|
||||
'DBStats.getReportDataSummaryByYear' => Piwik::translate('DBStats_ReportDataByYear')
|
||||
));
|
||||
}
|
||||
|
||||
private function configureViewForGetReportDataSummaryByYear(ViewDataTable $view)
|
||||
{
|
||||
$this->addBaseDisplayProperties($view);
|
||||
$this->addPresentationFilters($view);
|
||||
|
||||
$view->config->title = Piwik::translate('DBStats_ReportDataByYear');
|
||||
$view->config->addTranslation('label', Piwik::translate('CoreHome_PeriodYear'));
|
||||
$view->config->addRelatedReports(array(
|
||||
'DBStats.getReportDataSummary' => Piwik::translate('DBStats_ReportTables')
|
||||
));
|
||||
}
|
||||
|
||||
private function configureViewForGetIndividualReportsSummary(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);
|
||||
}
|
||||
|
||||
private function configureViewForGetIndividualMetricsSummary(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);
|
||||
}
|
||||
|
||||
private function configureViewForGetAdminDataSummary(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;
|
||||
}
|
||||
|
||||
private 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;
|
||||
}
|
||||
|
||||
$view->config->addTranslations(array(
|
||||
'label' => Piwik::translate('DBStats_Table'),
|
||||
'year' => Piwik::translate('CoreHome_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')
|
||||
));
|
||||
}
|
||||
|
||||
private 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 = true
|
||||
);
|
||||
|
||||
$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';
|
||||
|
||||
$runPrettySizeFilterBeforeGeneric = true;
|
||||
} 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';
|
||||
}
|
||||
}
|
||||
|
||||
$getPrettySize = array('\Piwik\MetricsFormatter', 'getPrettySizeFromBytes');
|
||||
$params = !isset($fixedMemoryUnit) ? array() : array($fixedMemoryUnit);
|
||||
|
||||
$view->config->filters[] = array('ColumnCallbackReplace', array($sizeColumns, $getPrettySize, $params), $runPrettySizeFilterBeforeGeneric);
|
||||
|
||||
// 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('\Piwik\MetricsFormatter', 'getPrettyNumber');
|
||||
$view->config->filters[] = array('ColumnCallbackReplace', array('row_count', $getPrettyNumber));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the footer message for the Individual...Summary reports.
|
||||
*/
|
||||
private function setIndividualSummaryFooterMessage(ViewDataTable $view)
|
||||
{
|
||||
$lastGenerated = self::getDateOfLastCachingRun();
|
||||
if ($lastGenerated !== false) {
|
||||
$view->config->show_footer_message = Piwik::translate('Mobile_LastUpdated', $lastGenerated);
|
||||
}
|
||||
}
|
||||
|
||||
public function setupTestEnvironment($environment)
|
||||
{
|
||||
Piwik::addAction("MySQLMetadataProvider.createDao", function (&$dao) {
|
||||
require_once dirname(__FILE__) . "/tests/Mocks/MockDataAccess.php";
|
||||
$dao = new Mocks\MockDataAccess();
|
||||
$dao = new MockDataAccess();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
26
www/analytics/plugins/DBStats/Menu.php
Normal file
26
www/analytics/plugins/DBStats/Menu.php
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
<?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;
|
||||
|
||||
use Piwik\Menu\MenuAdmin;
|
||||
use Piwik\Piwik;
|
||||
|
||||
/**
|
||||
*/
|
||||
class Menu extends \Piwik\Plugin\Menu
|
||||
{
|
||||
public function configureAdminMenu(MenuAdmin $menu)
|
||||
{
|
||||
if (Piwik::hasUserSuperUserAccess()) {
|
||||
$menu->addDiagnosticItem('DBStats_DatabaseUsage',
|
||||
$this->urlForAction('index'),
|
||||
$order = 6);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
/**
|
||||
* Piwik - Open source web analytics
|
||||
* Piwik - free/libre analytics platform
|
||||
*
|
||||
* @link http://piwik.org
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
|
||||
|
|
@ -8,9 +8,9 @@
|
|||
*/
|
||||
namespace Piwik\Plugins\DBStats;
|
||||
|
||||
use Piwik\Db;
|
||||
use Exception;
|
||||
use Piwik\Config;
|
||||
use \Exception;
|
||||
use Piwik\Db;
|
||||
|
||||
/**
|
||||
* Data Access Object that serves MySQL stats.
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
/**
|
||||
* Piwik - Open source web analytics
|
||||
* Piwik - free/libre analytics platform
|
||||
*
|
||||
* @link http://piwik.org
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
|
||||
|
|
@ -10,12 +10,10 @@ namespace Piwik\Plugins\DBStats;
|
|||
|
||||
use Exception;
|
||||
use Piwik\Common;
|
||||
use Piwik\Config;
|
||||
use Piwik\DataTable;
|
||||
use Piwik\Db;
|
||||
use Piwik\DbHelper;
|
||||
use Piwik\Option;
|
||||
use Piwik\Piwik;
|
||||
|
||||
/**
|
||||
* Utility class that provides general information about databases, including the size of
|
||||
|
|
@ -40,13 +38,9 @@ class MySQLMetadataProvider
|
|||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
public function __construct(MySQLMetadataDataAccess $dataAccess)
|
||||
{
|
||||
Piwik::postTestEvent("MySQLMetadataProvider.createDao", array(&$this->dataAccess));
|
||||
|
||||
if ($this->dataAccess === null) {
|
||||
$this->dataAccess = new MySQLMetadataDataAccess();
|
||||
}
|
||||
$this->dataAccess = $dataAccess;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
160
www/analytics/plugins/DBStats/Reports/Base.php
Normal file
160
www/analytics/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,33 @@
|
|||
<?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\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
|
||||
{
|
||||
|
||||
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,56 @@
|
|||
<?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
|
||||
{
|
||||
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,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;
|
||||
use Piwik\Plugins\CoreVisualizations\Visualizations\HtmlTable;
|
||||
|
||||
/**
|
||||
* Shows a datatable that displays how many occurances 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
|
||||
{
|
||||
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,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\Plugins\CoreVisualizations\Visualizations\HtmlTable;
|
||||
|
||||
/**
|
||||
* Shows a datatable that displays how many occurances 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
|
||||
{
|
||||
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,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;
|
||||
|
||||
/**
|
||||
* 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(
|
||||
self::factory('DBStats', 'getMetricDataSummaryByYear'),
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -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;
|
||||
|
||||
/**
|
||||
* 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(
|
||||
self::factory('DBStats', 'getMetricDataSummary'),
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
<?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 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(
|
||||
self::factory('DBStats', 'getReportDataSummaryByYear'),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -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;
|
||||
|
||||
/**
|
||||
* 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(
|
||||
self::factory('DBStats', 'getReportDataSummary'),
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
<?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\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
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
34
www/analytics/plugins/DBStats/Tasks.php
Normal file
34
www/analytics/plugins/DBStats/Tasks.php
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
<?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;
|
||||
|
||||
use Piwik\Date;
|
||||
use Piwik\Option;
|
||||
|
||||
class Tasks extends \Piwik\Plugin\Tasks
|
||||
{
|
||||
public function schedule()
|
||||
{
|
||||
$this->weekly('cacheDataByArchiveNameReports', null, self::LOWEST_PRIORITY);
|
||||
}
|
||||
|
||||
/**
|
||||
* Caches the intermediate DataTables used in the getIndividualReportsSummary and
|
||||
* getIndividualMetricsSummary reports in the option table.
|
||||
*/
|
||||
public function cacheDataByArchiveNameReports()
|
||||
{
|
||||
$api = API::getInstance();
|
||||
$api->getIndividualReportsSummary(true);
|
||||
$api->getIndividualMetricsSummary(true);
|
||||
|
||||
$now = Date::now()->getLocalized(Date::DATE_FORMAT_SHORT);
|
||||
Option::set(DBStats::TIME_OF_LAST_TASK_RUN_OPTION, $now);
|
||||
}
|
||||
}
|
||||
7
www/analytics/plugins/DBStats/config/test.php
Normal file
7
www/analytics/plugins/DBStats/config/test.php
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
<?php
|
||||
|
||||
return array(
|
||||
|
||||
'Piwik\Plugins\DBStats\MySQLMetadataDataAccess' => \DI\object('Piwik\Plugins\DBStats\tests\Mocks\MockDataAccess'),
|
||||
|
||||
);
|
||||
|
|
@ -7,7 +7,6 @@
|
|||
"LearnMore": "للإطلاع على المزيد حول كيفية معالجة Piwik للبيانات وكيفية ضبطه ليعمل على المواقع المتوسطة والكبيرة، انظر مستندات الدعم %s.",
|
||||
"MainDescription": "يقوم Piwik بتخزين كافة بيانات تحليلات ويب في قاعدة بيانات MySQL. حالياً، استهلك Piwik %s.",
|
||||
"MetricTables": "جداول المعيار",
|
||||
"PluginDescription": "هذا التطبيق يعطيك تقريراً عن مدى استهلاك قاعدة البيانات بواسطة جداول Piwik.",
|
||||
"ReportDataByYear": "جداول التقرير بالسنة",
|
||||
"RowCount": "عدد السطور",
|
||||
"Table": "الجدول",
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue