Move Mastodon API entities to src/Object
This commit is contained in:
parent
74a25eb670
commit
0de8e4db08
13 changed files with 24 additions and 25 deletions
39
src/Object/Api/Mastodon/Stats.php
Normal file
39
src/Object/Api/Mastodon/Stats.php
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
<?php
|
||||
|
||||
namespace Friendica\Object\Api\Mastodon;
|
||||
|
||||
use Friendica\BaseEntity;
|
||||
use Friendica\Core\Protocol;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\DI;
|
||||
|
||||
/**
|
||||
* Class Stats
|
||||
*
|
||||
* @see https://docs.joinmastodon.org/api/entities/#stats
|
||||
*/
|
||||
class Stats extends BaseEntity
|
||||
{
|
||||
/** @var int */
|
||||
protected $user_count = 0;
|
||||
/** @var int */
|
||||
protected $status_count = 0;
|
||||
/** @var int */
|
||||
protected $domain_count = 0;
|
||||
|
||||
/**
|
||||
* Creates a stats record
|
||||
*
|
||||
* @return Stats
|
||||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||
*/
|
||||
public static function get() {
|
||||
$stats = new Stats();
|
||||
if (!empty(DI::config()->get('system', 'nodeinfo'))) {
|
||||
$stats->user_count = intval(DI::config()->get('nodeinfo', 'total_users'));
|
||||
$stats->status_count = DI::config()->get('nodeinfo', 'local_posts') + DI::config()->get('nodeinfo', 'local_comments');
|
||||
$stats->domain_count = DBA::count('gserver', ["`network` in (?, ?) AND `last_contact` >= `last_failure`", Protocol::DFRN, Protocol::ACTIVITYPUB]);
|
||||
}
|
||||
return $stats;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue