Add user count and redirect page count statistics

This commit is contained in:
Starbeamrainbowlabs 2018-04-26 23:20:52 +01:00
parent 6fc44b7404
commit 0c00cf3631
Signed by: sbrl
GPG Key ID: 1BE5172E637709C2
4 changed files with 73 additions and 7 deletions

View File

@ -8,6 +8,8 @@ This file holds the changelog for Pepperminty Wiki. This is the master list of t
- Added page moves to the recent changes page (#151)
- Hyperlinked image preview on file pages to the original image (#153)
- Added the commit hash Pepperminty Wiki was built against to the master settings configuration page, and the debug action
- Added user count statistic
- Added redirect page count statistic
- [Rest API] Added support for the `mode` parameter to the `random` action
- [Rest API] Added `format` parameter to `recentchanges` action
- [Rest API] Added `comments-fetch` action to return a page's comments as JSON

View File

@ -387,7 +387,7 @@ if($settings->css === "auto")
/////////////////////////////////////////////////////////////////////////////
/** The version of Pepperminty Wiki currently running. */
$version = "v0.16-dev";
$commit = "3c21f371f680b6db44dc2b145809c49a6c56458e";
$commit = "6fc44b7404f98907a9f351b92654a0da7305a92e";
/// Environment ///
/** Holds information about the current request environment. */
$env = new stdClass();
@ -4761,8 +4761,22 @@ register_module([
//////////////////////////
/// Built-in Statisics ///
//////////////////////////
// The longest pages
statistic_add([
"id" => "user_count",
"name" => "Users",
"type" => "scalar",
"update" => function($old_stats) {
global $settings;
$result = new stdClass(); // completed, value, state
$result->completed = true;
$result->value = count(get_object_vars($settings->users));
return $result;
}
]);
statistic_add([
"id" => "longest-pages",
"name" => "Longest Pages",
@ -4825,6 +4839,24 @@ register_module([
return $result;
}
]);
statistic_add([
"id" => "redirect_count",
"name" => "Redirect Pages",
"type" => "scalar",
"update" => function($old_stats) {
global $pageindex;
$result = new stdClass(); // completed, value, state
$result->completed = true;
$result->value = 0;
foreach($pageindex as $pagename => $pagedata) {
if(!empty($pagedata->redirect) && $pagedata->redirect)
$result->value++;
}
return $result;
}
]);
// Perform an automatic recalculation of the statistics if needed
if($env->action !== "stats-update")
@ -7929,7 +7961,7 @@ register_module([
register_module([
"name" => "Parsedown",
"version" => "0.9.10",
"version" => "0.9.11",
"author" => "Emanuil Rusev & Starbeamrainbowlabs",
"description" => "An upgraded (now default!) parser based on Emanuil Rusev's Parsedown Extra PHP library (https://github.com/erusev/parsedown-extra), which is licensed MIT. Please be careful, as this module adds some weight to your installation, and also *requires* write access to the disk on first load.",
"id" => "parser-parsedown",

View File

@ -113,7 +113,7 @@
"author": "Starbeamrainbowlabs",
"description": "An extensible statistics calculation system. Comes with a range of built-in statistics, but can be extended by other modules too.",
"id": "feature-stats",
"lastupdate": 1505768903,
"lastupdate": 1524781183,
"optional": false
},
{
@ -262,11 +262,11 @@
},
{
"name": "Parsedown",
"version": "0.9.10",
"version": "0.9.11",
"author": "Emanuil Rusev & Starbeamrainbowlabs",
"description": "An upgraded (now default!) parser based on Emanuil Rusev's Parsedown Extra PHP library (https:\/\/github.com\/erusev\/parsedown-extra), which is licensed MIT. Please be careful, as this module adds some weight to your installation, and also *requires* write access to the disk on first load.",
"id": "parser-parsedown",
"lastupdate": 1524780647,
"lastupdate": 1524780823,
"optional": false
}
]

View File

@ -137,8 +137,22 @@ register_module([
//////////////////////////
/// Built-in Statisics ///
//////////////////////////
// The longest pages
statistic_add([
"id" => "user_count",
"name" => "Users",
"type" => "scalar",
"update" => function($old_stats) {
global $settings;
$result = new stdClass(); // completed, value, state
$result->completed = true;
$result->value = count(get_object_vars($settings->users));
return $result;
}
]);
statistic_add([
"id" => "longest-pages",
"name" => "Longest Pages",
@ -201,6 +215,24 @@ register_module([
return $result;
}
]);
statistic_add([
"id" => "redirect_count",
"name" => "Redirect Pages",
"type" => "scalar",
"update" => function($old_stats) {
global $pageindex;
$result = new stdClass(); // completed, value, state
$result->completed = true;
$result->value = 0;
foreach($pageindex as $pagename => $pagedata) {
if(!empty($pagedata->redirect) && $pagedata->redirect)
$result->value++;
}
return $result;
}
]);
// Perform an automatic recalculation of the statistics if needed
if($env->action !== "stats-update")