3 * GNU social - a federating social network
5 * LICENCE: This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU Affero General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU Affero General Public License for more details.
15 * You should have received a copy of the GNU Affero General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 if (!defined('GNUSOCIAL')) {
24 * Table Definition for Usage_stats
26 class Usage_stats extends Managed_DataObject
29 /* the code below is auto generated do not remove the above tag */
31 public $__table = 'usage_stats'; // table name
32 public $type; // varchar(191) unique_key not 255 because utf8mb4 takes more space
33 public $count; // int(4)
34 public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
36 /* the code above is auto generated do not remove the tag below */
39 public static function schemaDef()
42 'description' => 'node stats',
44 'type' => ['type' => 'varchar', 'length' => 191, 'description' => 'Type of countable entity'],
45 'count' => ['type' => 'int', 'size' => 'int', 'default' => 0, 'description' => 'Number of entities of this type'],
47 'modified' => ['type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'],
49 'primary key' => ['type'],
51 'usage_stats_key' => ['type'],
54 'user_stats_idx' => ['type'],
59 public function getUserCount()
61 return intval(Usage_stats::getKV('type', 'users')->count);
64 public function getPostCount()
66 return intval(Usage_stats::getKV('type', 'posts')->count);
69 public function getCommentCount()
71 return intval(Usage_stats::getKV('type', 'comments')->count);