Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/survey_server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjörn Schießle <bjoern@schiessle.org>2016-10-24 16:12:50 +0300
committerGitHub <noreply@github.com>2016-10-24 16:12:50 +0300
commit1060f117639a80a73ed8a48f80fe29009d12088c (patch)
tree7b32a2115530ed60ef5aecd88222fee4b94e50a6
parentac8dc69c01e838c60b66a99ac9a7a05b6046c22d (diff)
parent07e125bdceb2e714f8ba34351689c4388195b299 (diff)
Merge pull request #11 from nextcloud/better-stats
Better stats
-rw-r--r--js/script.js55
-rw-r--r--lib/BackgroundJobs/ComputeStatistics.php55
-rw-r--r--templates/part.content.php17
3 files changed, 101 insertions, 26 deletions
diff --git a/js/script.js b/js/script.js
index 026cc8f..1a87f8b 100644
--- a/js/script.js
+++ b/js/script.js
@@ -35,19 +35,24 @@
return color;
};
+ var formatNumber = function(number) {
+ number = number.toString();
+ return number.replace(/(\d)(?=(\d{3})+(\.|$))/g, '$1,');
+ };
+
/**
* add general statistics to the page
* @param instances how many instances are counted
* @param users statistics about the users
*/
var showGeneralStatistics = function(instances, users, files) {
- $('#instances span').text(instances);
- $('#maxUsers span').text(users['max']);
- $('#minUsers span').text(users['min']);
- $('#averageUsers span').text(users['average']);
- $('#maxFiles span').text(files['max']);
- $('#minFiles span').text(files['min']);
- $('#averageFiles span').text(files['average']);
+ $('#instances span').text(formatNumber(instances));
+ $('#maxUsers span').text(formatNumber(users['max']));
+ $('#minUsers span').text(formatNumber(users['min']));
+ $('#averageUsers span').text(formatNumber(users['average']));
+ $('#maxFiles span').text(formatNumber(files['max']));
+ $('#minFiles span').text(formatNumber(files['min']));
+ $('#averageFiles span').text(formatNumber(files['average']));
};
@@ -62,9 +67,9 @@
$('#' + id + 'Min span').text(OC.Util.humanFileSize(data['min']));
$('#' + id + 'Average span').text(OC.Util.humanFileSize(data['average']));
} else {
- $('#' + id + 'Max span').text(data['max']);
- $('#' + id + 'Min span').text(data['min']);
- $('#' + id + 'Average span').text(data['average']);
+ $('#' + id + 'Max span').text(formatNumber(data['max']));
+ $('#' + id + 'Min span').text(formatNumber(data['min']));
+ $('#' + id + 'Average span').text(formatNumber(data['average']));
}
};
@@ -74,11 +79,19 @@
* @param array data
*/
var appsChart = function (data) {
- var appLabels = new Array();
- var appValues = new Array();
- for (key in data) {
- appLabels.push(key);
- appValues.push(data[key]);
+ var appLabels = [],
+ appValues = [],
+ numApps = 0,
+ $details = $('#appDetails');
+ for (var key in data) {
+ $details.append($('<span>').text(key + ': ' + data[key]));
+ $details.append($('<br>'));
+
+ if (numApps < 75) {
+ appLabels.push(key);
+ appValues.push(100 * data[key] / (data['survey_client']));
+ numApps++;
+ }
}
var appData = {
@@ -105,8 +118,13 @@
* @param array data
*/
var ocChart = function (id, data) {
- var ocChartData = new Array();
+ var ocChartData = new Array(),
+ $details = $('#' + id + 'Details');
+
for (key in data) {
+ $details.append($('<span>').text(key + ': ' + data[key]));
+ $details.append($('<br>'));
+
ocChartData.push(
{
value: data[key],
@@ -116,9 +134,8 @@
);
}
- var ctx = document.getElementById(id).getContext("2d");
+ var ctx = document.getElementById(id + 'Chart').getContext("2d");
var myPieChart = new Chart(ctx).Pie(ocChartData);
-
};
$.get(
@@ -132,7 +149,7 @@
for(key in data['categories'][category]) {
if (key !== 'stats') {
if (data['categories'][category][key]['presentation'] === 'diagram') {
- ocChart(category + key + 'Chart', data['categories'][category][key]['statistics']);
+ ocChart((category + key).replace('.', '-'), data['categories'][category][key]['statistics']);
} else if (data['categories'][category][key]['presentation'] === 'numerical evaluation') {
ocNumericStatistics(category + key + 'Numeric', data['categories'][category][key]['statistics']);
}
diff --git a/lib/BackgroundJobs/ComputeStatistics.php b/lib/BackgroundJobs/ComputeStatistics.php
index 6ec38a8..7ab0518 100644
--- a/lib/BackgroundJobs/ComputeStatistics.php
+++ b/lib/BackgroundJobs/ComputeStatistics.php
@@ -122,16 +122,57 @@ class ComputeStatistics extends TimedJob {
$statistics = [];
foreach ($values as $value) {
- if (isset($statistics[$value['value']])) {
- $statistics[$value['value']] = $statistics[$value['value']] + 1;
+ $name = $this->clearValue($category, $key, $value['value']);
+ if (isset($statistics[$name])) {
+ $statistics[$name] = $statistics[$name] + 1;
} else {
- $statistics[$value['value']] = 1;
+ $statistics[$name] = 1;
}
}
+ arsort($statistics, SORT_NUMERIC);
return $statistics;
}
+ private function clearValue($category, $key, $value) {
+ if (strpos($key, 'memcache.') === 0) {
+ return $value !== '' ? trim($value, '\\') : 'none';
+ }
+
+ if ($key === 'version') {
+ $version = explode('.', $value);
+ $majorMinorVersion = $version[0] . '.' . (int) $version[1];
+
+ if ($category === 'server') {
+ return $majorMinorVersion . '.' . $version[2];
+ }
+
+ if ($category === 'database') {
+ switch ($version[0]) {
+ case '2':
+ case '3':
+ return 'SQLite ' . $majorMinorVersion;
+ case '5':
+ case '6':
+ return 'MySQL ' . $majorMinorVersion;
+ case '10':
+ case '11':
+ return 'MariaDB ' . $majorMinorVersion;
+ default:
+ return $majorMinorVersion;
+ }
+ }
+
+ return $majorMinorVersion;
+ }
+
+ if ($key === 'max_execution_time') {
+ return $value . 's';
+ }
+
+ return (string) $value;
+ }
+
private function getNumericalEvaluatedStatistics($category, $key) {
$query = $this->connection->getQueryBuilder();
@@ -195,9 +236,15 @@ class ComputeStatistics extends TimedJob {
}
$max = $statistics['survey_client'];
+ $apps = \OC::$server->getAppManager()->getAlwaysEnabledApps();
+ $apps = array_flip($apps);
foreach ($statistics as $key => $value) {
- $statistics[$key] = 100/$max*$value;
+ if (!isset($apps[$key])) {
+ $statistics[$key] = $value;
+ } else {
+ unset($statistics[$key]);
+ }
}
arsort($statistics);
diff --git a/templates/part.content.php b/templates/part.content.php
index dc419b9..139c50e 100644
--- a/templates/part.content.php
+++ b/templates/part.content.php
@@ -53,8 +53,14 @@
</div>
<div class="section" id="enabledApps">
- <h1>Enabled Apps (in % of installations)</h1>
- <canvas id="appChart" width="800" height="400"></canvas>
+ <h1>Enabled Apps</h1>
+
+ <h2>Top 75 (in %)</h2>
+ <canvas id="appChart" width="1000" height="400"></canvas>
+
+ <details id="appDetails">
+ <summary><strong>Full list</strong></summary>
+ </details>
</div>
<?php foreach ($_['statistics']['categories'] as $category => $data) { ?>
@@ -80,7 +86,12 @@
<?php if ($value['presentation'] === \OCA\Survey_Server\EvaluateStatistics::PRESENTATION_TYPE_DIAGRAM) {?>
<div class="chart">
<h2><?php p(($value['description']));?></h2>
- <canvas id="<?php p($category . $key . 'Chart');?>" width="400" height="300"></canvas>
+
+ <details id="<?php p(str_replace('.', '-', $category . $key) . 'Details');?>">
+ <summary>
+ <canvas id="<?php p(str_replace('.', '-', $category . $key) . 'Chart');?>" width="400" height="300"></canvas>
+ </summary>
+ </details>
</div>
<?php }
} ?>