[NodeInfo] New endpoint and formula for computing active users

Seriously improved documentation
Now NodeInfo 2.0 is available at /api/nodeinfo/2.0.json
For active users we now also consider favourites and recently created accounts
Some further minor bug fixes and full review of the implementation
This commit is contained in:
Diogo Cordeiro
2019-08-12 04:45:25 +01:00
parent c0ac7f0ac8
commit e4bdb21a54
7 changed files with 519 additions and 179 deletions

View File

@@ -1,32 +1,32 @@
#!/usr/bin/env php
<?php
// This file is part of GNU social - https://www.gnu.org/software/social
//
// GNU social is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// GNU social is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with GNU social. If not, see <http://www.gnu.org/licenses/>.
/**
* GNU social - a federating social network
* Fix Nodeinfo statistics
*
* LICENCE: This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @category Plugin
* @package GNUsocial
* @copyright 2018 Free Software Foundation http://fsf.org
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
* @link https://www.gnu.org/software/social/
* @package NodeInfo
* @author Diogo Cordeiro <diogo@fc.up.pt>
* @copyright 2019 Free Software Foundation, Inc http://www.fsf.org
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
*/
define('INSTALLDIR', realpath(__DIR__ . '/../../..'));
define('INSTALLDIR', dirname(dirname(dirname(__DIR__))));
if (!defined('NODEINFO_UPGRADE')) {
$longoptions = ['type='];
$helptext = <<<END_OF_HELP
@@ -53,7 +53,6 @@ END_OF_HELP;
if ($verbose) {
echo "Started.\n\n";
}
} else {
echo "Nodeinfo will now fix stats\n";
$type_to_fix = 'all';
@@ -95,7 +94,13 @@ if ($verbose) {
* Counting functions
*/
function getUserCount()
/**
* Total number of users
*
* @return int
* @author Stéphane Bérubé <chimo@chromic.org>
*/
function getUserCount(): int
{
$users = new User();
$userCount = $users->count();
@@ -103,6 +108,12 @@ function getUserCount()
return $userCount;
}
/**
* Total number of dents
*
* @return int
* @author Stéphane Bérubé <chimo@chromic.org>
*/
function getPostCount()
{
$notices = new Notice();
@@ -113,6 +124,12 @@ function getPostCount()
return $noticeCount;
}
/**
* Total number of replies
*
* @return int
* @author Stéphane Bérubé <chimo@chromic.org>
*/
function getCommentCount()
{
$notices = new Notice();