mirror of
https://github.com/friendica/friendica
synced 2025-04-28 11:44:23 +02:00
More statistics variables added
This commit is contained in:
parent
64433739c2
commit
3445e91781
3 changed files with 61 additions and 8 deletions
|
@ -419,6 +419,14 @@ class Item
|
|||
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?
|
||||
if (($item['origin'] || $parent['origin']) && ($item['uid'] != 0)) {
|
||||
if ($item['origin'] && $item['gravity'] == self::GRAVITY_PARENT) {
|
||||
|
@ -428,7 +436,7 @@ class Item
|
|||
$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);
|
||||
|
||||
|
@ -1455,6 +1463,14 @@ class Item
|
|||
}
|
||||
|
||||
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.
|
||||
if (in_array($posted_item['gravity'], [self::GRAVITY_PARENT, self::GRAVITY_COMMENT])) {
|
||||
self::updateDisplayCache($posted_item['uri-id']);
|
||||
|
|
|
@ -69,6 +69,11 @@ class Nodeinfo
|
|||
DI::keyValue()->set('nodeinfo_local_posts', $posts);
|
||||
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]);
|
||||
}
|
||||
|
||||
|
@ -76,7 +81,7 @@ class Nodeinfo
|
|||
* Return the supported services
|
||||
*
|
||||
* @return Object with supported services
|
||||
*/
|
||||
*/
|
||||
public static function getUsage(bool $version2 = false)
|
||||
{
|
||||
$config = DI::config();
|
||||
|
@ -103,7 +108,7 @@ class Nodeinfo
|
|||
* Return the supported services
|
||||
*
|
||||
* @return array with supported services
|
||||
*/
|
||||
*/
|
||||
public static function getServices(): array
|
||||
{
|
||||
$services = [
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue