#!/usr/bin/env php . * * @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/ */ define('INSTALLDIR', realpath(__DIR__ . '/../../..')); $longoptions = ['type=']; $helptext = <<count = getUserCount(); $us->update(); } if ($type_to_fix == 'all' || $type_to_fix == 'posts') { if ($verbose) { echo "[+] Updating Posts stats...\n"; } $us = Usage_stats::getKV('posts'); $us->count = getPostCount(); $us->update(); } if ($type_to_fix == 'all' || $type_to_fix == 'comments') { if ($verbose) { echo "[+] Updating Comments stats...\n"; } $us = Usage_stats::getKV('comments'); $us->count = getCommentCount(); $us->update(); } if ($verbose) { echo "\nDONE.\n"; } /* * Counting functions */ function getUserCount() { $users = new User(); $userCount = $users->count(); return $userCount; } function getPostCount() { $notices = new Notice(); $notices->is_local = Notice::LOCAL_PUBLIC; $notices->whereAdd('reply_to IS NULL'); $noticeCount = $notices->count(); return $noticeCount; } function getCommentCount() { $notices = new Notice(); $notices->is_local = Notice::LOCAL_PUBLIC; $notices->whereAdd('reply_to IS NOT NULL'); $commentCount = $notices->count(); return $commentCount; }