1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- <?php
- defined('GNUSOCIAL') || die();
- class Usage_stats extends Managed_DataObject
- {
- public $__table = 'usage_stats';
- public $type;
- public $count;
- public $modified;
-
- public static function schemaDef(): array
- {
- return [
- 'description' => 'node stats',
- 'fields' => [
- 'type' => ['type' => 'varchar', 'not null' => true, 'length' => 191, 'description' => 'Type of countable entity'],
- 'count' => ['type' => 'int', 'size' => 'int', 'default' => 0, 'description' => 'Number of entities of this type'],
- 'modified' => ['type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'],
- ],
- 'primary key' => ['type'],
- 'indexes' => [
- 'user_stats_idx' => ['type'],
- ],
- ];
- }
-
- public function getUserCount(): int
- {
- return Usage_stats::getKV('type', 'users')->count;
- }
-
- public function getPostCount(): int
- {
- return Usage_stats::getKV('type', 'posts')->count;
- }
-
- public function getCommentCount(): int
- {
- return Usage_stats::getKV('type', 'comments')->count;
- }
- }
|