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) {
$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);
}
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']);
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]);
}
* Return the supported services
*
* @return Object with supported services
- */
+ */
public static function getUsage(bool $version2 = false)
{
$config = DI::config();
* Return the supported services
*
* @return array with supported services
- */
+ */
public static function getServices(): array
{
$services = [
use Friendica\Core\L10n;
use Friendica\Core\Worker;
use Friendica\Database\Database;
+use Friendica\Model\Register;
+use Friendica\Moderation\Entity\Report;
use Friendica\Util\DateTimeFormat;
use Friendica\Util\Profiler;
use Psr\Log\LoggerInterface;
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 = [
+ 'cron' => [
+ 'lastExecution' => [
+ 'datetime' => DateTimeFormat::utc($this->keyValue->get('last_cron'), DateTimeFormat::JSON),
+ 'timestamp' => (int)$this->keyValue->get('last_cron'),
+ ],
+ ],
'worker' => [
'lastExecution' => [
'datetime' => DateTimeFormat::utc($this->keyValue->get('last_worker_execution'), DateTimeFormat::JSON),
],
'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')),
+ 'activeMonth' => intval($this->keyValue->get('nodeinfo_active_users_monthly')),
+ 'activeHalfyear' => intval($this->keyValue->get('nodeinfo_active_users_halfyear')),
+ 'pending' => Register::getPendingCount(),
],
- 'usage' => [
- 'localPosts' => intval($this->keyValue->get('nodeinfo_local_posts')),
- 'localComments' => intval($this->keyValue->get('nodeinfo_local_comments')),
+ 'posts' => [
+ 'inbound' => [
+ '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);