mirror of
https://github.com/friendica/friendica
synced 2024-12-23 04:00:15 +00:00
Merge pull request #14317 from annando/stats2
More statistics variables added
This commit is contained in:
commit
ca5f93a4d5
3 changed files with 61 additions and 8 deletions
|
@ -419,6 +419,14 @@ class Item
|
||||||
self::markForDeletion(['parent' => $item['parent'], 'deleted' => false], $priority);
|
self::markForDeletion(['parent' => $item['parent'], 'deleted' => false], $priority);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($item['uid'] == 0 && $item['gravity'] == self::GRAVITY_PARENT) {
|
||||||
|
$posts = DI::keyValue()->get('nodeinfo_total_posts') ?? 0;
|
||||||
|
DI::keyValue()->set('nodeinfo_total_posts', $posts - 1);
|
||||||
|
} elseif ($item['uid'] == 0 && $item['gravity'] == self::GRAVITY_COMMENT) {
|
||||||
|
$comments = DI::keyValue()->get('nodeinfo_total_comments') ?? 0;
|
||||||
|
DI::keyValue()->set('nodeinfo_total_comments', $comments - 1);
|
||||||
|
}
|
||||||
|
|
||||||
// Is it our comment and/or our thread?
|
// Is it our comment and/or our thread?
|
||||||
if (($item['origin'] || $parent['origin']) && ($item['uid'] != 0)) {
|
if (($item['origin'] || $parent['origin']) && ($item['uid'] != 0)) {
|
||||||
if ($item['origin'] && $item['gravity'] == self::GRAVITY_PARENT) {
|
if ($item['origin'] && $item['gravity'] == self::GRAVITY_PARENT) {
|
||||||
|
@ -1455,6 +1463,14 @@ class Item
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($inserted) {
|
if ($inserted) {
|
||||||
|
if ($posted_item['gravity'] == self::GRAVITY_PARENT) {
|
||||||
|
$posts = DI::keyValue()->get('nodeinfo_total_posts') ?? 0;
|
||||||
|
DI::keyValue()->set('nodeinfo_total_posts', $posts + 1);
|
||||||
|
} elseif ($posted_item['gravity'] == self::GRAVITY_COMMENT) {
|
||||||
|
$comments = DI::keyValue()->get('nodeinfo_total_comments') ?? 0;
|
||||||
|
DI::keyValue()->set('nodeinfo_total_comments', $comments + 1);
|
||||||
|
}
|
||||||
|
|
||||||
// Fill the cache with the rendered content.
|
// Fill the cache with the rendered content.
|
||||||
if (in_array($posted_item['gravity'], [self::GRAVITY_PARENT, self::GRAVITY_COMMENT])) {
|
if (in_array($posted_item['gravity'], [self::GRAVITY_PARENT, self::GRAVITY_COMMENT])) {
|
||||||
self::updateDisplayCache($posted_item['uri-id']);
|
self::updateDisplayCache($posted_item['uri-id']);
|
||||||
|
|
|
@ -69,6 +69,11 @@ class Nodeinfo
|
||||||
DI::keyValue()->set('nodeinfo_local_posts', $posts);
|
DI::keyValue()->set('nodeinfo_local_posts', $posts);
|
||||||
DI::keyValue()->set('nodeinfo_local_comments', $comments);
|
DI::keyValue()->set('nodeinfo_local_comments', $comments);
|
||||||
|
|
||||||
|
$posts = DBA::count('post', ['deleted' => false, 'gravity' => Item::GRAVITY_COMMENT]);
|
||||||
|
$comments = DBA::count('post', ['deleted' => false, 'gravity' => Item::GRAVITY_COMMENT]);
|
||||||
|
DI::keyValue()->set('nodeinfo_total_posts', $posts);
|
||||||
|
DI::keyValue()->set('nodeinfo_total_comments', $comments);
|
||||||
|
|
||||||
$logger->info('Post statistics - done', ['posts' => $posts, 'comments' => $comments]);
|
$logger->info('Post statistics - done', ['posts' => $posts, 'comments' => $comments]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,6 +28,8 @@ use Friendica\Core\KeyValueStorage\Capability\IManageKeyValuePairs;
|
||||||
use Friendica\Core\L10n;
|
use Friendica\Core\L10n;
|
||||||
use Friendica\Core\Worker;
|
use Friendica\Core\Worker;
|
||||||
use Friendica\Database\Database;
|
use Friendica\Database\Database;
|
||||||
|
use Friendica\Model\Register;
|
||||||
|
use Friendica\Moderation\Entity\Report;
|
||||||
use Friendica\Util\DateTimeFormat;
|
use Friendica\Util\DateTimeFormat;
|
||||||
use Friendica\Util\Profiler;
|
use Friendica\Util\Profiler;
|
||||||
use Psr\Log\LoggerInterface;
|
use Psr\Log\LoggerInterface;
|
||||||
|
@ -67,7 +69,22 @@ class Stats extends BaseModule
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$report = $this->dba->selectFirst('report', ['created'], [], ['order' => ['created' => true]]);
|
||||||
|
if (!empty($report)) {
|
||||||
|
$report_datetime = DateTimeFormat::utc($report['created'], DateTimeFormat::JSON);
|
||||||
|
$report_timestamp = strtotime($report['created']);
|
||||||
|
} else {
|
||||||
|
$report_datetime = '';
|
||||||
|
$report_timestamp = 0;
|
||||||
|
}
|
||||||
|
|
||||||
$statistics = [
|
$statistics = [
|
||||||
|
'cron' => [
|
||||||
|
'lastExecution' => [
|
||||||
|
'datetime' => DateTimeFormat::utc($this->keyValue->get('last_cron'), DateTimeFormat::JSON),
|
||||||
|
'timestamp' => (int)$this->keyValue->get('last_cron'),
|
||||||
|
],
|
||||||
|
],
|
||||||
'worker' => [
|
'worker' => [
|
||||||
'lastExecution' => [
|
'lastExecution' => [
|
||||||
'datetime' => DateTimeFormat::utc($this->keyValue->get('last_worker_execution'), DateTimeFormat::JSON),
|
'datetime' => DateTimeFormat::utc($this->keyValue->get('last_worker_execution'), DateTimeFormat::JSON),
|
||||||
|
@ -84,14 +101,29 @@ class Stats extends BaseModule
|
||||||
],
|
],
|
||||||
'users' => [
|
'users' => [
|
||||||
'total' => intval($this->keyValue->get('nodeinfo_total_users')),
|
'total' => intval($this->keyValue->get('nodeinfo_total_users')),
|
||||||
'activeHalfyear' => intval($this->keyValue->get('nodeinfo_active_users_halfyear')),
|
|
||||||
'activeMonth' => intval($this->keyValue->get('nodeinfo_active_users_monthly')),
|
|
||||||
'activeWeek' => intval($this->keyValue->get('nodeinfo_active_users_weekly')),
|
'activeWeek' => intval($this->keyValue->get('nodeinfo_active_users_weekly')),
|
||||||
|
'activeMonth' => intval($this->keyValue->get('nodeinfo_active_users_monthly')),
|
||||||
|
'activeHalfyear' => intval($this->keyValue->get('nodeinfo_active_users_halfyear')),
|
||||||
|
'pending' => Register::getPendingCount(),
|
||||||
],
|
],
|
||||||
'usage' => [
|
'posts' => [
|
||||||
'localPosts' => intval($this->keyValue->get('nodeinfo_local_posts')),
|
'inbound' => [
|
||||||
'localComments' => intval($this->keyValue->get('nodeinfo_local_comments')),
|
'posts' => intval($this->keyValue->get('nodeinfo_total_posts')) - intval($this->keyValue->get('nodeinfo_local_posts')),
|
||||||
|
'comments' => intval($this->keyValue->get('nodeinfo_total_comments')) - intval($this->keyValue->get('nodeinfo_local_comments')),
|
||||||
],
|
],
|
||||||
|
'outbound' => [
|
||||||
|
'posts' => intval($this->keyValue->get('nodeinfo_local_posts')),
|
||||||
|
'comments' => intval($this->keyValue->get('nodeinfo_local_comments')),
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'reports' => [
|
||||||
|
'newest' => [
|
||||||
|
'datetime' => $report_datetime,
|
||||||
|
'timestamp' => $report_timestamp,
|
||||||
|
],
|
||||||
|
'open' => $this->dba->count('report', ['status' => Report::STATUS_OPEN]),
|
||||||
|
'closed' => $this->dba->count('report', ['status' => Report::STATUS_CLOSED]),
|
||||||
|
]
|
||||||
];
|
];
|
||||||
|
|
||||||
$statistics = $this->getJobsPerPriority($statistics);
|
$statistics = $this->getJobsPerPriority($statistics);
|
||||||
|
|
Loading…
Reference in a new issue