mirror of
https://github.com/friendica/friendica
synced 2025-04-28 12:24:23 +02:00
New endpoint for monitoring services
This commit is contained in:
parent
8e094a2dd0
commit
53d121de51
6 changed files with 173 additions and 5 deletions
|
@ -421,6 +421,14 @@ class Item
|
|||
|
||||
// Is it our comment and/or our thread?
|
||||
if (($item['origin'] || $parent['origin']) && ($item['uid'] != 0)) {
|
||||
if ($item['origin'] && $item['gravity'] == self::GRAVITY_PARENT) {
|
||||
$posts = DI::keyValue()->get('nodeinfo_local_posts') ?? 0;
|
||||
DI::keyValue()->set('nodeinfo_local_posts', $posts - 1);
|
||||
} elseif ($item['origin'] && $item['gravity'] == self::GRAVITY_COMMENT) {
|
||||
$comments = DI::keyValue()->get('nodeinfo_local_comments') ?? 0;
|
||||
DI::keyValue()->set('nodeinfo_local_comments', $comments - 1);
|
||||
}
|
||||
|
||||
// When we delete the original post we will delete all existing copies on the server as well
|
||||
self::markForDeletion(['uri-id' => $item['uri-id'], 'deleted' => false], $priority);
|
||||
|
||||
|
@ -1350,6 +1358,14 @@ class Item
|
|||
return 0;
|
||||
}
|
||||
|
||||
if ($posted_item['origin'] && $posted_item['gravity'] == self::GRAVITY_PARENT) {
|
||||
$posts = DI::keyValue()->get('nodeinfo_local_posts') ?? 0;
|
||||
DI::keyValue()->set('nodeinfo_local_posts', $posts + 1);
|
||||
} elseif ($posted_item['origin'] && $posted_item['gravity'] == self::GRAVITY_COMMENT) {
|
||||
$comments = DI::keyValue()->get('nodeinfo_local_comments') ?? 0;
|
||||
DI::keyValue()->set('nodeinfo_local_comments', $comments + 1);
|
||||
}
|
||||
|
||||
Post\Origin::insert($posted_item);
|
||||
|
||||
// update the commented timestamp on the parent
|
||||
|
|
|
@ -53,6 +53,8 @@ class Nodeinfo
|
|||
return;
|
||||
}
|
||||
|
||||
$logger->info('User statistics - start');
|
||||
|
||||
$userStats = User::getStatistics();
|
||||
|
||||
DI::keyValue()->set('nodeinfo_total_users', $userStats['total_users']);
|
||||
|
@ -60,14 +62,14 @@ class Nodeinfo
|
|||
DI::keyValue()->set('nodeinfo_active_users_monthly', $userStats['active_users_monthly']);
|
||||
DI::keyValue()->set('nodeinfo_active_users_weekly', $userStats['active_users_weekly']);
|
||||
|
||||
$logger->info('user statistics', $userStats);
|
||||
$logger->info('user statistics - done', $userStats);
|
||||
|
||||
$posts = DBA::count('post-thread', ["`uri-id` IN (SELECT `uri-id` FROM `post-user` WHERE NOT `deleted` AND `origin`)"]);
|
||||
$comments = DBA::count('post', ["NOT `deleted` AND `gravity` = ? AND `uri-id` IN (SELECT `uri-id` FROM `post-user` WHERE `origin`)", Item::GRAVITY_COMMENT]);
|
||||
DI::keyValue()->set('nodeinfo_local_posts', $posts);
|
||||
DI::keyValue()->set('nodeinfo_local_comments', $comments);
|
||||
|
||||
$logger->info('User activity', ['posts' => $posts, 'comments' => $comments]);
|
||||
$logger->info('Post statistics - done', ['posts' => $posts, 'comments' => $comments]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue