Umbau der Statistik Ausgabe (each enfernt)

Optimierungen
This commit is contained in:
Gregor Schulte
2021-11-29 15:23:19 +01:00
parent b303dd00d6
commit c464f9e3a3
18 changed files with 580 additions and 545 deletions

View File

@@ -1,5 +1,5 @@
<?php
define('PICONTROL', true);
const PICONTROL = true;
(include_once realpath(dirname(__FILE__)).'/../../resources/init.php') or die('Error: 0x0000');
(include_once LIBRARY_PATH.'main/main.function.php') or die('Error: 0x0001');
@@ -14,34 +14,34 @@ if (isset($_POST['id']))
{
$controller = new StatisticController();
$controller->loadStatistics();
if (($name = $controller->getStatisticName($_POST['id'])) !== false)
{
if (isset($_POST['plugin']) && trim($_POST['plugin']) != '')
pluginLanguage(trim($_POST['plugin']));
$builder = new StatisticBuilder();
$builder->loadFromFile($name, (isset($_POST['plugin']) && trim($_POST['plugin']) != '') ? $_POST['plugin'] : NULL);
$statistic = $builder->getArray();
$log = new LogStatistic();
$log->setFile(LOG_PATH.$statistic['raw'].'.csv');
$arr = $info = array();
foreach ($statistic['columns'] as $column)
$arr['cols'][] = array('id' => '', 'label' => _t($column['label']), 'type' => $column['type']);
getRowsFromLog($arr, $info, $log->getAll(), $statistic['columns'], $statistic['cycle']);
if (isset($arr['rows']))
{
if (isset($_POST['type']) && $_POST['type'] == 'googleChart')
$arr['rows'] = convertForGoogleChart($arr['rows']);
$arr['rows'] = array_slice($arr['rows'], -2016);
$arr['periods'] = $info['periods'];
foreach (array('min', 'max') as $type)
{
if ($statistic['limits'][$type]['use'] == 'multiply')
@@ -54,7 +54,7 @@ if (isset($_POST['id']))
$arr[$type] = round($info[$type]);
}
}
$api->addData('statistic', $arr);
}
else
@@ -67,23 +67,22 @@ else
{
$statistics = array();
$hiddenStatistics = unserialize(htmlspecialchars_decode(getConfig('main:statistic.hidden', 'a:0:{}')));
$controller = new StatisticController();
$controller->loadStatistics();
foreach ($controller->getStatistics() as $statistic)
{
$builder = new StatisticBuilder();
$builder->loadFromFile($statistic);
$array = $builder->getArray();
if (!in_array($builder->getId(), $hiddenStatistics))
$statistics[] = array('array' => $array);
}
$api->addData('statistics', $statistics);
$api->addData('hidden', $hiddenStatistics);
}
$api->display();
?>