From 92a71f8c27de8c1abd182be9f8bef441e1e60166 Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 6 Feb 2022 20:03:19 +0000 Subject: [PATCH 1/5] Store wekk/month&halfyear usage / number of posts --- database.sql | 7 ++- doc/database/db_gserver.md | 55 +++++++++-------- src/Model/GServer.php | 105 ++++++++++++++++++++++++++++++++ src/Module/Admin/Federation.php | 1 + static/dbstructure.config.php | 7 ++- 5 files changed, 148 insertions(+), 27 deletions(-) diff --git a/database.sql b/database.sql index 692b5deb7..ed136e620 100644 --- a/database.sql +++ b/database.sql @@ -1,6 +1,6 @@ -- ------------------------------------------ -- Friendica 2021.12-rc (Siberian Iris) --- DB_UPDATE_VERSION 1449 +-- DB_UPDATE_VERSION 1450 -- ------------------------------------------ @@ -16,6 +16,11 @@ CREATE TABLE IF NOT EXISTS `gserver` ( `info` text COMMENT '', `register_policy` tinyint NOT NULL DEFAULT 0 COMMENT '', `registered-users` int unsigned NOT NULL DEFAULT 0 COMMENT 'Number of registered users', + `active-week-users` int unsigned COMMENT 'Number of active users in the last week', + `active-month-users` int unsigned COMMENT 'Number of active users in the last month', + `active-halfyear-users` int unsigned COMMENT 'Number of active users in the last six month', + `local-posts` int unsigned COMMENT 'Number of local posts', + `local-comments` int unsigned COMMENT 'Number of local comments', `directory-type` tinyint DEFAULT 0 COMMENT 'Type of directory service (Poco, Mastodon)', `poco` varchar(255) NOT NULL DEFAULT '' COMMENT '', `noscrape` varchar(255) NOT NULL DEFAULT '' COMMENT '', diff --git a/doc/database/db_gserver.md b/doc/database/db_gserver.md index 905602b3b..d75c7335b 100644 --- a/doc/database/db_gserver.md +++ b/doc/database/db_gserver.md @@ -6,31 +6,36 @@ Global servers Fields ------ -| Field | Description | Type | Null | Key | Default | Extra | -| ---------------- | -------------------------------------------------- | ---------------- | ---- | --- | ------------------- | -------------- | -| id | sequential ID | int unsigned | NO | PRI | NULL | auto_increment | -| url | | varchar(255) | NO | | | | -| nurl | | varchar(255) | NO | | | | -| version | | varchar(255) | NO | | | | -| site_name | | varchar(255) | NO | | | | -| info | | text | YES | | NULL | | -| register_policy | | tinyint | NO | | 0 | | -| registered-users | Number of registered users | int unsigned | NO | | 0 | | -| directory-type | Type of directory service (Poco, Mastodon) | tinyint | YES | | 0 | | -| poco | | varchar(255) | NO | | | | -| noscrape | | varchar(255) | NO | | | | -| network | | char(4) | NO | | | | -| protocol | The protocol of the server | tinyint unsigned | YES | | NULL | | -| platform | | varchar(255) | NO | | | | -| relay-subscribe | Has the server subscribed to the relay system | boolean | NO | | 0 | | -| relay-scope | The scope of messages that the server wants to get | varchar(10) | NO | | | | -| detection-method | Method that had been used to detect that server | tinyint unsigned | YES | | NULL | | -| created | | datetime | NO | | 0001-01-01 00:00:00 | | -| last_poco_query | | datetime | YES | | 0001-01-01 00:00:00 | | -| last_contact | Last successful connection request | datetime | YES | | 0001-01-01 00:00:00 | | -| last_failure | Last failed connection request | datetime | YES | | 0001-01-01 00:00:00 | | -| failed | Connection failed | boolean | YES | | NULL | | -| next_contact | Next connection request | datetime | YES | | 0001-01-01 00:00:00 | | +| Field | Description | Type | Null | Key | Default | Extra | +| --------------------- | -------------------------------------------------- | ---------------- | ---- | --- | ------------------- | -------------- | +| id | sequential ID | int unsigned | NO | PRI | NULL | auto_increment | +| url | | varchar(255) | NO | | | | +| nurl | | varchar(255) | NO | | | | +| version | | varchar(255) | NO | | | | +| site_name | | varchar(255) | NO | | | | +| info | | text | YES | | NULL | | +| register_policy | | tinyint | NO | | 0 | | +| registered-users | Number of registered users | int unsigned | NO | | 0 | | +| active-week-users | Number of active users in the last week | int unsigned | YES | | NULL | | +| active-month-users | Number of active users in the last month | int unsigned | YES | | NULL | | +| active-halfyear-users | Number of active users in the last six month | int unsigned | YES | | NULL | | +| local-posts | Number of local posts | int unsigned | YES | | NULL | | +| local-comments | Number of local comments | int unsigned | YES | | NULL | | +| directory-type | Type of directory service (Poco, Mastodon) | tinyint | YES | | 0 | | +| poco | | varchar(255) | NO | | | | +| noscrape | | varchar(255) | NO | | | | +| network | | char(4) | NO | | | | +| protocol | The protocol of the server | tinyint unsigned | YES | | NULL | | +| platform | | varchar(255) | NO | | | | +| relay-subscribe | Has the server subscribed to the relay system | boolean | NO | | 0 | | +| relay-scope | The scope of messages that the server wants to get | varchar(10) | NO | | | | +| detection-method | Method that had been used to detect that server | tinyint unsigned | YES | | NULL | | +| created | | datetime | NO | | 0001-01-01 00:00:00 | | +| last_poco_query | | datetime | YES | | 0001-01-01 00:00:00 | | +| last_contact | Last successful connection request | datetime | YES | | 0001-01-01 00:00:00 | | +| last_failure | Last failed connection request | datetime | YES | | 0001-01-01 00:00:00 | | +| failed | Connection failed | boolean | YES | | NULL | | +| next_contact | Next connection request | datetime | YES | | 0001-01-01 00:00:00 | | Indexes ------------ diff --git a/src/Model/GServer.php b/src/Model/GServer.php index 90b023f6f..c4138cc2d 100644 --- a/src/Model/GServer.php +++ b/src/Model/GServer.php @@ -377,6 +377,12 @@ class GServer if (empty($nodeinfo['network']) || in_array($nodeinfo['network'], [Protocol::DFRN, Protocol::ZOT])) { if (!empty($nodeinfo['detection-method'])) { $serverdata['detection-method'] = $nodeinfo['detection-method']; + + foreach (['registered-users', 'active_users_monthly', 'active-halfyear-users', 'local-posts'] as $field) { + if (!empty($nodeinfo[$field])) { + $serverdata[$field] = $nodeinfo[$field]; + } + } } // Fetch the landing page, possibly it reveals some data @@ -500,6 +506,10 @@ class GServer $serverdata = self::detectNetworkViaContacts($url, $serverdata); } + if ($serverdata['network'] == Protocol::ACTIVITYPUB) { + $serverdata = self::fetchWeeklyUsage($url, $serverdata); + } + $serverdata['registered-users'] = $serverdata['registered-users'] ?? 0; // On an active server there has to be at least a single user @@ -687,6 +697,21 @@ class GServer } } + if (!empty($data['total_users'])) { + $serverdata['registered-users'] = max($data['total_users'], 1); + } + + if (!empty($data['active_users_monthly'])) { + $serverdata['active-month-users'] = max($data['active_users_monthly'], 0); + } + + if (!empty($data['active_users_halfyear'])) { + $serverdata['active-halfyear-users'] = max($data['active_users_halfyear'], 0); + } + + if (!empty($data['local_posts'])) { + $serverdata['local-posts'] = max($data['local_posts'], 0); + } if (!empty($data['registrations_open'])) { $serverdata['register_policy'] = Register::OPEN; @@ -801,6 +826,22 @@ class GServer $server['registered-users'] = max($nodeinfo['usage']['users']['total'], 1); } + if (!empty($nodeinfo['usage']['users']['activeMonth'])) { + $server['active-month-users'] = max($nodeinfo['usage']['users']['activeMonth'], 0); + } + + if (!empty($nodeinfo['usage']['users']['activeHalfyear'])) { + $server['active-halfyear-users'] = max($nodeinfo['usage']['users']['activeHalfyear'], 0); + } + + if (!empty($nodeinfo['usage']['localPosts'])) { + $server['local-posts'] = max($nodeinfo['usage']['localPosts'], 0); + } + + if (!empty($nodeinfo['usage']['localComments'])) { + $server['local-comments'] = max($nodeinfo['usage']['localComments'], 0); + } + if (!empty($nodeinfo['protocols']['inbound']) && is_array($nodeinfo['protocols']['inbound'])) { $protocols = []; foreach ($nodeinfo['protocols']['inbound'] as $protocol) { @@ -878,6 +919,22 @@ class GServer $server['registered-users'] = max($nodeinfo['usage']['users']['total'], 1); } + if (!empty($nodeinfo['usage']['users']['activeMonth'])) { + $server['active-month-users'] = max($nodeinfo['usage']['users']['activeMonth'], 0); + } + + if (!empty($nodeinfo['usage']['users']['activeHalfyear'])) { + $server['active-halfyear-users'] = max($nodeinfo['usage']['users']['activeHalfyear'], 0); + } + + if (!empty($nodeinfo['usage']['localPosts'])) { + $server['local-posts'] = max($nodeinfo['usage']['localPosts'], 0); + } + + if (!empty($nodeinfo['usage']['localComments'])) { + $server['local-comments'] = max($nodeinfo['usage']['localComments'], 0); + } + if (!empty($nodeinfo['protocols'])) { $protocols = []; foreach ($nodeinfo['protocols'] as $protocol) { @@ -957,6 +1014,22 @@ class GServer $serverdata['registered-users'] = max($data['channels_total'], 1); } + if (!empty($data['channels_active_monthly'])) { + $serverdata['active-month-users'] = max($data['channels_active_monthly'], 0); + } + + if (!empty($data['channels_active_halfyear'])) { + $serverdata['active-halfyear-users'] = max($data['channels_active_halfyear'], 0); + } + + if (!empty($data['local_posts'])) { + $serverdata['local-posts'] = max($data['local_posts'], 0); + } + + if (!empty($data['local_comments'])) { + $serverdata['local-comments'] = max($data['local_comments'], 0); + } + if (!empty($data['register_policy'])) { switch ($data['register_policy']) { case 'REGISTER_OPEN': @@ -1208,6 +1281,38 @@ class GServer return $serverdata; } + private static function fetchWeeklyUsage(string $url, array $serverdata) { + $curlResult = DI::httpClient()->get($url . '/api/v1/instance/activity'); + + if (!$curlResult->isSuccess() || ($curlResult->getBody() == '')) { + return $serverdata; + } + + $data = json_decode($curlResult->getBody(), true); + if (empty($data)) { + return $serverdata; + } + + $current_week = []; + foreach ($data as $week) { + // Use only data from a full week + if (empty($week['week']) || (time() - $week['week']) < 7 * 24 * 60 * 60) { + continue; + } + + // Most likely the data is sorted correctly. But we better are safe than sorry + if (empty($current_week['week']) || ($current_week['week'] < $week['week'])) { + $current_week = $week; + } + } + + if (!empty($current_week['logins'])) { + $serverdata['active-week-users'] = max($current_week['logins'], 0); + } + + return $serverdata; + } + /** * Detects data from a given server url if it was a mastodon alike system * diff --git a/src/Module/Admin/Federation.php b/src/Module/Admin/Federation.php index 119196189..fbd782ad5 100644 --- a/src/Module/Admin/Federation.php +++ b/src/Module/Admin/Federation.php @@ -43,6 +43,7 @@ class Federation extends BaseAdmin 'diaspora' => ['name' => 'Diaspora', 'color' => '#a1a1a1'], // logo is black and white, makes a gray 'funkwhale' => ['name' => 'Funkwhale', 'color' => '#4082B4'], // From the homepage 'gnusocial' => ['name' => 'GNU Social/Statusnet', 'color' => '#a22430'], // dark red from the logo + 'hometown' => ['name' => 'Hometown', 'color' => '#1f70c1'], // Color from the Patreon page 'hubzilla' => ['name' => 'Hubzilla/Red Matrix', 'color' => '#43488a'], // blue from the logo 'lemmy' => ['name' => 'Lemmy', 'color' => '#00c853'], // Green from the page 'mastodon' => ['name' => 'Mastodon', 'color' => '#1a9df9'], // blue from the Mastodon logo diff --git a/static/dbstructure.config.php b/static/dbstructure.config.php index 39481348e..2e1a2191c 100644 --- a/static/dbstructure.config.php +++ b/static/dbstructure.config.php @@ -55,7 +55,7 @@ use Friendica\Database\DBA; if (!defined('DB_UPDATE_VERSION')) { - define('DB_UPDATE_VERSION', 1449); + define('DB_UPDATE_VERSION', 1450); } return [ @@ -71,6 +71,11 @@ return [ "info" => ["type" => "text", "comment" => ""], "register_policy" => ["type" => "tinyint", "not null" => "1", "default" => "0", "comment" => ""], "registered-users" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "comment" => "Number of registered users"], + "active-week-users" => ["type" => "int unsigned", "comment" => "Number of active users in the last week"], + "active-month-users" => ["type" => "int unsigned", "comment" => "Number of active users in the last month"], + "active-halfyear-users" => ["type" => "int unsigned", "comment" => "Number of active users in the last six month"], + "local-posts" => ["type" => "int unsigned", "comment" => "Number of local posts"], + "local-comments" => ["type" => "int unsigned", "comment" => "Number of local comments"], "directory-type" => ["type" => "tinyint", "default" => "0", "comment" => "Type of directory service (Poco, Mastodon)"], "poco" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""], "noscrape" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""], From 2fdd33f504f9284a5834e3c39e1531d99c9df70a Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 6 Feb 2022 20:05:29 +0000 Subject: [PATCH 2/5] Updated database.sql --- database.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/database.sql b/database.sql index ed136e620..b7a923618 100644 --- a/database.sql +++ b/database.sql @@ -1,5 +1,5 @@ -- ------------------------------------------ --- Friendica 2021.12-rc (Siberian Iris) +-- Friendica 2022.05-dev (Siberian Iris) -- DB_UPDATE_VERSION 1450 -- ------------------------------------------ From 58b4ecd6ae7e9e504620ba609bf2f75cb70d9ced Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 7 Feb 2022 05:29:00 +0000 Subject: [PATCH 3/5] Show month/halfyear usage --- src/Module/Admin/Federation.php | 29 +++++--- view/lang/C/messages.po | 111 ++++++++++++++-------------- view/templates/admin/federation.tpl | 2 +- 3 files changed, 76 insertions(+), 66 deletions(-) diff --git a/src/Module/Admin/Federation.php b/src/Module/Admin/Federation.php index fbd782ad5..19f114942 100644 --- a/src/Module/Admin/Federation.php +++ b/src/Module/Admin/Federation.php @@ -58,6 +58,7 @@ class Federation extends BaseAdmin 'relay' => ['name' => 'ActivityPub Relay', 'color' => '#888888'], // Grey like the second color of the ActivityPub logo 'socialhome' => ['name' => 'SocialHome', 'color' => '#52056b'], // lilac from the Django Image used at the Socialhome homepage 'wordpress' => ['name' => 'WordPress', 'color' => '#016087'], // Background color of the homepage + 'write.as' => ['name' => 'Write.as', 'color' => '#00ace3'], // Border color of the homepage 'writefreely' => ['name' => 'WriteFreely', 'color' => '#292929'], // Font color of the homepage 'other' => ['name' => DI::l10n()->t('Other'), 'color' => '#F1007E'], // ActivityPub main color ]; @@ -69,15 +70,21 @@ class Federation extends BaseAdmin $counts[$platform] = []; } - $total = 0; - $users = 0; + $total = 0; + $users = 0; + $month = 0; + $halfyear = 0; - $gservers = DBA::p("SELECT COUNT(*) AS `total`, SUM(`registered-users`) AS `users`, `platform`, + $gservers = DBA::p("SELECT COUNT(*) AS `total`, SUM(`registered-users`) AS `users`, + SUM(IFNULL(`active-month-users`, `active-week-users`)) AS `month`, + SUM(IFNULL(`active-halfyear-users`, `active-week-users`)) AS `halfyear`, `platform`, ANY_VALUE(`network`) AS `network`, MAX(`version`) AS `version` FROM `gserver` WHERE NOT `failed` AND `detection-method` != ? AND NOT `network` IN (?, ?) GROUP BY `platform`", GServer::DETECT_MANUAL, Protocol::PHANTOM, Protocol::FEED); while ($gserver = DBA::fetch($gservers)) { - $total += $gserver['total']; - $users += $gserver['users']; + $total += $gserver['total']; + $users += $gserver['users']; + $month += $gserver['month']; + $halfyear += $gserver['halfyear']; $versionCounts = []; $versions = DBA::p("SELECT COUNT(*) AS `total`, `version` FROM `gserver` @@ -127,9 +134,11 @@ class Federation extends BaseAdmin $versionCounts = array_merge($versionCounts, $counts[$platform][1] ?? []); } - $gserver['platform'] = $platform; - $gserver['total'] += $counts[$platform][0]['total'] ?? 0; - $gserver['users'] += $counts[$platform][0]['users'] ?? 0; + $gserver['platform'] = $platform; + $gserver['total'] += $counts[$platform][0]['total'] ?? 0; + $gserver['users'] += $counts[$platform][0]['users'] ?? 0; + $gserver['month'] += $counts[$platform][0]['month'] ?? 0; + $gserver['halfyear'] += $counts[$platform][0]['halfyear'] ?? 0; } if ($platform == 'friendica') { @@ -152,7 +161,7 @@ class Federation extends BaseAdmin $gserver['platform'] = $systems[$platform]['name']; - $counts[$platform] = [$gserver, $versionCounts, str_replace([' ', '%'], '', $platform), $systems[$platform]['color']]; + $counts[$platform] = [$gserver, $versionCounts, str_replace([' ', '%', '.'], '', $platform), $systems[$platform]['color']]; } DBA::close($gserver); @@ -167,7 +176,7 @@ class Federation extends BaseAdmin '$intro' => $intro, '$counts' => $counts, '$version' => FRIENDICA_VERSION, - '$legendtext' => DI::l10n()->t('Currently this node is aware of %d nodes with %d registered users from the following platforms:', $total, $users), + '$legendtext' => DI::l10n()->t('Currently this node is aware of %d nodes (%d active users last month, %d active users last six month, %d registered users in total) from the following platforms:', $total, $month, $halfyear, $users), ]); } diff --git a/view/lang/C/messages.po b/view/lang/C/messages.po index 692f0f53d..9bd54a310 100644 --- a/view/lang/C/messages.po +++ b/view/lang/C/messages.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: 2022.05-dev\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2022-01-28 05:23+0000\n" +"POT-Creation-Date: 2022-02-07 05:22+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -118,7 +118,7 @@ msgid "The feed for this item is unavailable." msgstr "" #: mod/editpost.php:38 mod/events.php:220 mod/follow.php:56 mod/follow.php:130 -#: mod/item.php:185 mod/item.php:190 mod/item.php:940 mod/message.php:69 +#: mod/item.php:185 mod/item.php:190 mod/item.php:930 mod/message.php:69 #: mod/message.php:111 mod/notes.php:44 mod/ostatus_subscribe.php:32 #: mod/photos.php:160 mod/photos.php:897 mod/repair_ostatus.php:31 #: mod/settings.php:46 mod/settings.php:56 mod/settings.php:412 @@ -464,7 +464,7 @@ msgstr "" msgid "OStatus support is disabled. Contact can't be added." msgstr "" -#: mod/follow.php:138 src/Content/Item.php:463 src/Content/Widget.php:76 +#: mod/follow.php:138 src/Content/Item.php:452 src/Content/Widget.php:76 #: src/Model/Contact.php:1056 src/Model/Contact.php:1068 #: view/theme/vier/theme.php:172 msgid "Connect/Follow" @@ -518,19 +518,19 @@ msgstr "" msgid "Empty post discarded." msgstr "" -#: mod/item.php:746 +#: mod/item.php:736 msgid "Post updated." msgstr "" -#: mod/item.php:756 mod/item.php:761 +#: mod/item.php:746 mod/item.php:751 msgid "Item wasn't stored." msgstr "" -#: mod/item.php:772 +#: mod/item.php:762 msgid "Item couldn't be fetched." msgstr "" -#: mod/item.php:918 src/Module/Admin/Themes/Details.php:39 +#: mod/item.php:908 src/Module/Admin/Themes/Details.php:39 #: src/Module/Admin/Themes/Index.php:59 src/Module/Debug/ItemBody.php:41 #: src/Module/Debug/ItemBody.php:56 msgid "Item not found." @@ -1965,15 +1965,15 @@ msgstr "" msgid "Friend Suggestions" msgstr "" -#: mod/tagger.php:78 src/Content/Item.php:346 src/Model/Item.php:2629 +#: mod/tagger.php:78 src/Content/Item.php:335 src/Model/Item.php:2620 msgid "photo" msgstr "" -#: mod/tagger.php:78 src/Content/Item.php:341 src/Content/Item.php:350 +#: mod/tagger.php:78 src/Content/Item.php:330 src/Content/Item.php:339 msgid "status" msgstr "" -#: mod/tagger.php:111 src/Content/Item.php:360 +#: mod/tagger.php:111 src/Content/Item.php:349 #, php-format msgid "%1$s tagged %2$s's %3$s with %4$s" msgstr "" @@ -2714,55 +2714,55 @@ msgstr "" msgid "show more" msgstr "" -#: src/Content/Item.php:305 +#: src/Content/Item.php:294 #, php-format msgid "%1$s poked %2$s" msgstr "" -#: src/Content/Item.php:338 src/Model/Item.php:2627 +#: src/Content/Item.php:327 src/Model/Item.php:2618 msgid "event" msgstr "" -#: src/Content/Item.php:442 view/theme/frio/theme.php:254 +#: src/Content/Item.php:431 view/theme/frio/theme.php:254 msgid "Follow Thread" msgstr "" -#: src/Content/Item.php:443 src/Model/Contact.php:1061 +#: src/Content/Item.php:432 src/Model/Contact.php:1061 msgid "View Status" msgstr "" -#: src/Content/Item.php:444 src/Content/Item.php:466 src/Model/Contact.php:995 +#: src/Content/Item.php:433 src/Content/Item.php:455 src/Model/Contact.php:995 #: src/Model/Contact.php:1053 src/Model/Contact.php:1062 #: src/Module/Directory.php:157 src/Module/Settings/Profile/Index.php:225 msgid "View Profile" msgstr "" -#: src/Content/Item.php:445 src/Model/Contact.php:1063 +#: src/Content/Item.php:434 src/Model/Contact.php:1063 msgid "View Photos" msgstr "" -#: src/Content/Item.php:446 src/Model/Contact.php:1054 +#: src/Content/Item.php:435 src/Model/Contact.php:1054 #: src/Model/Contact.php:1064 msgid "Network Posts" msgstr "" -#: src/Content/Item.php:447 src/Model/Contact.php:1055 +#: src/Content/Item.php:436 src/Model/Contact.php:1055 #: src/Model/Contact.php:1065 msgid "View Contact" msgstr "" -#: src/Content/Item.php:448 src/Model/Contact.php:1066 +#: src/Content/Item.php:437 src/Model/Contact.php:1066 msgid "Send PM" msgstr "" -#: src/Content/Item.php:449 src/Module/Admin/Blocklist/Contact.php:100 +#: src/Content/Item.php:438 src/Module/Admin/Blocklist/Contact.php:100 #: src/Module/Admin/Users/Active.php:140 src/Module/Admin/Users/Index.php:154 #: src/Module/Contact.php:398 src/Module/Contact/Profile.php:348 #: src/Module/Contact/Profile.php:449 msgid "Block" msgstr "" -#: src/Content/Item.php:450 src/Module/Contact.php:399 +#: src/Content/Item.php:439 src/Module/Contact.php:399 #: src/Module/Contact/Profile.php:349 src/Module/Contact/Profile.php:457 #: src/Module/Notifications/Introductions.php:132 #: src/Module/Notifications/Introductions.php:204 @@ -2770,11 +2770,11 @@ msgstr "" msgid "Ignore" msgstr "" -#: src/Content/Item.php:454 src/Object/Post.php:429 +#: src/Content/Item.php:443 src/Object/Post.php:429 msgid "Languages" msgstr "" -#: src/Content/Item.php:458 src/Model/Contact.php:1067 +#: src/Content/Item.php:447 src/Model/Contact.php:1067 msgid "Poke" msgstr "" @@ -3070,8 +3070,8 @@ msgid "" "%2$s %3$s" msgstr "" -#: src/Content/Text/BBCode.php:1185 src/Model/Item.php:3158 -#: src/Model/Item.php:3164 src/Model/Item.php:3165 +#: src/Content/Text/BBCode.php:1185 src/Model/Item.php:3149 +#: src/Model/Item.php:3155 src/Model/Item.php:3156 msgid "Link to source" msgstr "" @@ -4067,63 +4067,63 @@ msgstr "" msgid "Forum" msgstr "" -#: src/Model/Contact.php:2426 +#: src/Model/Contact.php:2433 msgid "Disallowed profile URL." msgstr "" -#: src/Model/Contact.php:2431 src/Module/Friendica.php:81 +#: src/Model/Contact.php:2438 src/Module/Friendica.php:81 msgid "Blocked domain" msgstr "" -#: src/Model/Contact.php:2436 +#: src/Model/Contact.php:2443 msgid "Connect URL missing." msgstr "" -#: src/Model/Contact.php:2445 +#: src/Model/Contact.php:2452 msgid "" "The contact could not be added. Please check the relevant network " "credentials in your Settings -> Social Networks page." msgstr "" -#: src/Model/Contact.php:2482 +#: src/Model/Contact.php:2489 msgid "The profile address specified does not provide adequate information." msgstr "" -#: src/Model/Contact.php:2484 +#: src/Model/Contact.php:2491 msgid "No compatible communication protocols or feeds were discovered." msgstr "" -#: src/Model/Contact.php:2487 +#: src/Model/Contact.php:2494 msgid "An author or name was not found." msgstr "" -#: src/Model/Contact.php:2490 +#: src/Model/Contact.php:2497 msgid "No browser URL could be matched to this address." msgstr "" -#: src/Model/Contact.php:2493 +#: src/Model/Contact.php:2500 msgid "" "Unable to match @-style Identity Address with a known protocol or email " "contact." msgstr "" -#: src/Model/Contact.php:2494 +#: src/Model/Contact.php:2501 msgid "Use mailto: in front of address to force email check." msgstr "" -#: src/Model/Contact.php:2500 +#: src/Model/Contact.php:2507 msgid "" "The profile address specified belongs to a network which has been disabled " "on this site." msgstr "" -#: src/Model/Contact.php:2505 +#: src/Model/Contact.php:2512 msgid "" "Limited profile. This person will be unable to receive direct/personal " "notifications from you." msgstr "" -#: src/Model/Contact.php:2564 +#: src/Model/Contact.php:2571 msgid "Unable to retrieve contact information." msgstr "" @@ -4243,33 +4243,33 @@ msgstr "" msgid "Edit groups" msgstr "" -#: src/Model/Item.php:1680 +#: src/Model/Item.php:1691 #, php-format msgid "Detected languages in this post:\\n%s" msgstr "" -#: src/Model/Item.php:2631 +#: src/Model/Item.php:2622 msgid "activity" msgstr "" -#: src/Model/Item.php:2633 +#: src/Model/Item.php:2624 msgid "comment" msgstr "" -#: src/Model/Item.php:2636 +#: src/Model/Item.php:2627 msgid "post" msgstr "" -#: src/Model/Item.php:2773 +#: src/Model/Item.php:2764 #, php-format msgid "Content warning: %s" msgstr "" -#: src/Model/Item.php:3123 +#: src/Model/Item.php:3114 msgid "bytes" msgstr "" -#: src/Model/Item.php:3152 src/Model/Item.php:3153 +#: src/Model/Item.php:3143 src/Model/Item.php:3144 msgid "View on separate page" msgstr "" @@ -4699,7 +4699,7 @@ msgstr "" #: src/Module/Admin/Blocklist/Contact.php:94 #: src/Module/Admin/Blocklist/Server/Add.php:89 #: src/Module/Admin/Blocklist/Server/Index.php:78 -#: src/Module/Admin/Federation.php:159 src/Module/Admin/Item/Delete.php:64 +#: src/Module/Admin/Federation.php:174 src/Module/Admin/Item/Delete.php:64 #: src/Module/Admin/Logs/Settings.php:79 src/Module/Admin/Logs/View.php:83 #: src/Module/Admin/Queue.php:72 src/Module/Admin/Site.php:498 #: src/Module/Admin/Storage.php:138 src/Module/Admin/Summary.php:232 @@ -5109,29 +5109,30 @@ msgstr "" msgid "Manage Additional Features" msgstr "" -#: src/Module/Admin/Federation.php:56 +#: src/Module/Admin/Federation.php:63 msgid "Other" msgstr "" -#: src/Module/Admin/Federation.php:118 src/Module/Admin/Federation.php:348 +#: src/Module/Admin/Federation.php:131 src/Module/Admin/Federation.php:363 msgid "unknown" msgstr "" -#: src/Module/Admin/Federation.php:154 +#: src/Module/Admin/Federation.php:169 msgid "" "This page offers you some numbers to the known part of the federated social " "network your Friendica node is part of. These numbers are not complete but " "only reflect the part of the network your node is aware of." msgstr "" -#: src/Module/Admin/Federation.php:160 src/Module/BaseAdmin.php:87 +#: src/Module/Admin/Federation.php:175 src/Module/BaseAdmin.php:87 msgid "Federation Statistics" msgstr "" -#: src/Module/Admin/Federation.php:164 +#: src/Module/Admin/Federation.php:179 #, php-format msgid "" -"Currently this node is aware of %d nodes with %d registered users from the " +"Currently this node is aware of %d nodes (%d active users last month, %d " +"active users last six month, %d registered users in total) from the " "following platforms:" msgstr "" @@ -8605,19 +8606,19 @@ msgstr "" #: src/Module/Profile/Profile.php:326 src/Module/Profile/Profile.php:329 #: src/Module/Profile/Status.php:65 src/Module/Profile/Status.php:68 -#: src/Protocol/Feed.php:985 src/Protocol/OStatus.php:1242 +#: src/Protocol/Feed.php:990 src/Protocol/OStatus.php:1242 #, php-format msgid "%s's timeline" msgstr "" #: src/Module/Profile/Profile.php:327 src/Module/Profile/Status.php:66 -#: src/Protocol/Feed.php:989 src/Protocol/OStatus.php:1246 +#: src/Protocol/Feed.php:994 src/Protocol/OStatus.php:1246 #, php-format msgid "%s's posts" msgstr "" #: src/Module/Profile/Profile.php:328 src/Module/Profile/Status.php:67 -#: src/Protocol/Feed.php:992 src/Protocol/OStatus.php:1249 +#: src/Protocol/Feed.php:997 src/Protocol/OStatus.php:1249 #, php-format msgid "%s's comments" msgstr "" diff --git a/view/templates/admin/federation.tpl b/view/templates/admin/federation.tpl index 37e3cb847..e80565fd1 100644 --- a/view/templates/admin/federation.tpl +++ b/view/templates/admin/federation.tpl @@ -10,7 +10,7 @@
    {{foreach $counts as $c}} {{if $c[0]['total'] > 0}} -
  • {{$c[0]['platform']}} ({{$c[0]['total']}}/{{$c[0]['users']}})
  • +
  • {{$c[0]['platform']}} ({{$c[0]['total']}} • {{$c[0]['month']}} • {{$c[0]['halfyear']}} • {{$c[0]['users']}})
  • {{/if}} {{/foreach}}
From bdba75ec473f070dc39455aad9a518b13c3d18b0 Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 7 Feb 2022 06:11:37 +0000 Subject: [PATCH 4/5] Show detailled statistics per platform --- src/Module/Admin/Federation.php | 16 ++++++++++++- view/lang/C/messages.po | 35 ++++++++++++++++++++++++----- view/templates/admin/federation.tpl | 13 ++++++++++- 3 files changed, 57 insertions(+), 7 deletions(-) diff --git a/src/Module/Admin/Federation.php b/src/Module/Admin/Federation.php index 19f114942..94b26f461 100644 --- a/src/Module/Admin/Federation.php +++ b/src/Module/Admin/Federation.php @@ -74,8 +74,10 @@ class Federation extends BaseAdmin $users = 0; $month = 0; $halfyear = 0; + $posts = 0; $gservers = DBA::p("SELECT COUNT(*) AS `total`, SUM(`registered-users`) AS `users`, + SUM(IFNULL(`local-posts`, 0) + IFNULL(`local-comments`, 0)) AS `posts`, SUM(IFNULL(`active-month-users`, `active-week-users`)) AS `month`, SUM(IFNULL(`active-halfyear-users`, `active-week-users`)) AS `halfyear`, `platform`, ANY_VALUE(`network`) AS `network`, MAX(`version`) AS `version` @@ -85,6 +87,7 @@ class Federation extends BaseAdmin $users += $gserver['users']; $month += $gserver['month']; $halfyear += $gserver['halfyear']; + $posts += $gserver['posts']; $versionCounts = []; $versions = DBA::p("SELECT COUNT(*) AS `total`, `version` FROM `gserver` @@ -139,6 +142,7 @@ class Federation extends BaseAdmin $gserver['users'] += $counts[$platform][0]['users'] ?? 0; $gserver['month'] += $counts[$platform][0]['month'] ?? 0; $gserver['halfyear'] += $counts[$platform][0]['halfyear'] ?? 0; + $gserver['posts'] += $counts[$platform][0]['posts'] ?? 0; } if ($platform == 'friendica') { @@ -159,7 +163,17 @@ class Federation extends BaseAdmin ksort($versionCounts); } - $gserver['platform'] = $systems[$platform]['name']; + $gserver['platform'] = $systems[$platform]['name']; + $gserver['monthlbl'] = DI::l10n()->t('%d active users last month', $gserver['month']); + $gserver['halfyearlbl'] = DI::l10n()->t('%d active users last six month', $gserver['halfyear']); + $gserver['userslbl'] = DI::l10n()->t('%d registered users', $gserver['users']); + $gserver['postslbl'] = DI::l10n()->t('%d local posts', $gserver['posts']); + + if (($gserver['users'] > 0) && ($gserver['posts'] > 0)) { + $gserver['postsuserlbl'] = DI::l10n()->t('%d posts per user', $gserver['posts'] / $gserver['users']); + } else { + $gserver['postsuserlbl'] = ''; + } $counts[$platform] = [$gserver, $versionCounts, str_replace([' ', '%', '.'], '', $platform), $systems[$platform]['color']]; } diff --git a/view/lang/C/messages.po b/view/lang/C/messages.po index 9bd54a310..24f06bce9 100644 --- a/view/lang/C/messages.po +++ b/view/lang/C/messages.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: 2022.05-dev\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2022-02-07 05:22+0000\n" +"POT-Creation-Date: 2022-02-07 06:11+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -4699,7 +4699,7 @@ msgstr "" #: src/Module/Admin/Blocklist/Contact.php:94 #: src/Module/Admin/Blocklist/Server/Add.php:89 #: src/Module/Admin/Blocklist/Server/Index.php:78 -#: src/Module/Admin/Federation.php:174 src/Module/Admin/Item/Delete.php:64 +#: src/Module/Admin/Federation.php:188 src/Module/Admin/Item/Delete.php:64 #: src/Module/Admin/Logs/Settings.php:79 src/Module/Admin/Logs/View.php:83 #: src/Module/Admin/Queue.php:72 src/Module/Admin/Site.php:498 #: src/Module/Admin/Storage.php:138 src/Module/Admin/Summary.php:232 @@ -5113,22 +5113,47 @@ msgstr "" msgid "Other" msgstr "" -#: src/Module/Admin/Federation.php:131 src/Module/Admin/Federation.php:363 +#: src/Module/Admin/Federation.php:134 src/Module/Admin/Federation.php:377 msgid "unknown" msgstr "" +#: src/Module/Admin/Federation.php:167 +#, php-format +msgid "%d active users last month" +msgstr "" + +#: src/Module/Admin/Federation.php:168 +#, php-format +msgid "%d active users last six month" +msgstr "" + #: src/Module/Admin/Federation.php:169 +#, php-format +msgid "%d registered users" +msgstr "" + +#: src/Module/Admin/Federation.php:170 +#, php-format +msgid "%d local posts" +msgstr "" + +#: src/Module/Admin/Federation.php:173 +#, php-format +msgid "%d posts per user" +msgstr "" + +#: src/Module/Admin/Federation.php:183 msgid "" "This page offers you some numbers to the known part of the federated social " "network your Friendica node is part of. These numbers are not complete but " "only reflect the part of the network your node is aware of." msgstr "" -#: src/Module/Admin/Federation.php:175 src/Module/BaseAdmin.php:87 +#: src/Module/Admin/Federation.php:189 src/Module/BaseAdmin.php:87 msgid "Federation Statistics" msgstr "" -#: src/Module/Admin/Federation.php:179 +#: src/Module/Admin/Federation.php:193 #, php-format msgid "" "Currently this node is aware of %d nodes (%d active users last month, %d " diff --git a/view/templates/admin/federation.tpl b/view/templates/admin/federation.tpl index e80565fd1..d99d72e5f 100644 --- a/view/templates/admin/federation.tpl +++ b/view/templates/admin/federation.tpl @@ -10,7 +10,7 @@
    {{foreach $counts as $c}} {{if $c[0]['total'] > 0}} -
  • {{$c[0]['platform']}} ({{$c[0]['total']}} • {{$c[0]['month']}} • {{$c[0]['halfyear']}} • {{$c[0]['users']}})
  • +
  • {{$c[0]['platform']}} ({{$c[0]['total']}}/{{$c[0]['users']}})
  • {{/if}} {{/foreach}}
@@ -60,6 +60,17 @@ {{$c[0]['total']}} {{$c[0]['network']}} + + +
    + {{if $c[0]['month']}}
  • {{$c[0]['monthlbl']}}
  • {{/if}} + {{if $c[0]['halfyear']}}
  • {{$c[0]['halfyearlbl']}}
  • {{/if}} + {{if $c[0]['users']}}
  • {{$c[0]['userslbl']}}
  • {{/if}} + {{if $c[0]['posts']}}
  • {{$c[0]['postslbl']}}
  • {{/if}} + {{if $c[0]['postsuserlbl']}}
  • {{$c[0]['postsuserlbl']}}
  • {{/if}} +
+ + From 384fe562a8dff1bbc584c17e78c4f79bf3d5b7e9 Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 7 Feb 2022 06:23:49 +0000 Subject: [PATCH 5/5] More statistics --- src/Module/Admin/Federation.php | 6 ++++++ view/lang/C/messages.po | 30 +++++++++++++++++++---------- view/templates/admin/federation.tpl | 2 ++ 3 files changed, 28 insertions(+), 10 deletions(-) diff --git a/src/Module/Admin/Federation.php b/src/Module/Admin/Federation.php index 94b26f461..63564ed29 100644 --- a/src/Module/Admin/Federation.php +++ b/src/Module/Admin/Federation.php @@ -164,6 +164,7 @@ class Federation extends BaseAdmin } $gserver['platform'] = $systems[$platform]['name']; + $gserver['totallbl'] = DI::l10n()->t('%d total systems', $gserver['total']); $gserver['monthlbl'] = DI::l10n()->t('%d active users last month', $gserver['month']); $gserver['halfyearlbl'] = DI::l10n()->t('%d active users last six month', $gserver['halfyear']); $gserver['userslbl'] = DI::l10n()->t('%d registered users', $gserver['users']); @@ -174,6 +175,11 @@ class Federation extends BaseAdmin } else { $gserver['postsuserlbl'] = ''; } + if (($gserver['users'] > 0) && ($gserver['total'] > 0)) { + $gserver['userssystemlbl'] = DI::l10n()->t('%d users per system', $gserver['users'] / $gserver['total']); + } else { + $gserver['userssystemlbl'] = ''; + } $counts[$platform] = [$gserver, $versionCounts, str_replace([' ', '%', '.'], '', $platform), $systems[$platform]['color']]; } diff --git a/view/lang/C/messages.po b/view/lang/C/messages.po index 24f06bce9..32dd77a33 100644 --- a/view/lang/C/messages.po +++ b/view/lang/C/messages.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: 2022.05-dev\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2022-02-07 06:11+0000\n" +"POT-Creation-Date: 2022-02-07 06:23+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -4699,7 +4699,7 @@ msgstr "" #: src/Module/Admin/Blocklist/Contact.php:94 #: src/Module/Admin/Blocklist/Server/Add.php:89 #: src/Module/Admin/Blocklist/Server/Index.php:78 -#: src/Module/Admin/Federation.php:188 src/Module/Admin/Item/Delete.php:64 +#: src/Module/Admin/Federation.php:194 src/Module/Admin/Item/Delete.php:64 #: src/Module/Admin/Logs/Settings.php:79 src/Module/Admin/Logs/View.php:83 #: src/Module/Admin/Queue.php:72 src/Module/Admin/Site.php:498 #: src/Module/Admin/Storage.php:138 src/Module/Admin/Summary.php:232 @@ -5113,47 +5113,57 @@ msgstr "" msgid "Other" msgstr "" -#: src/Module/Admin/Federation.php:134 src/Module/Admin/Federation.php:377 +#: src/Module/Admin/Federation.php:134 src/Module/Admin/Federation.php:383 msgid "unknown" msgstr "" #: src/Module/Admin/Federation.php:167 #, php-format -msgid "%d active users last month" +msgid "%d total systems" msgstr "" #: src/Module/Admin/Federation.php:168 #, php-format -msgid "%d active users last six month" +msgid "%d active users last month" msgstr "" #: src/Module/Admin/Federation.php:169 #, php-format -msgid "%d registered users" +msgid "%d active users last six month" msgstr "" #: src/Module/Admin/Federation.php:170 #, php-format +msgid "%d registered users" +msgstr "" + +#: src/Module/Admin/Federation.php:171 +#, php-format msgid "%d local posts" msgstr "" -#: src/Module/Admin/Federation.php:173 +#: src/Module/Admin/Federation.php:174 #, php-format msgid "%d posts per user" msgstr "" -#: src/Module/Admin/Federation.php:183 +#: src/Module/Admin/Federation.php:179 +#, php-format +msgid "%d users per system" +msgstr "" + +#: src/Module/Admin/Federation.php:189 msgid "" "This page offers you some numbers to the known part of the federated social " "network your Friendica node is part of. These numbers are not complete but " "only reflect the part of the network your node is aware of." msgstr "" -#: src/Module/Admin/Federation.php:189 src/Module/BaseAdmin.php:87 +#: src/Module/Admin/Federation.php:195 src/Module/BaseAdmin.php:87 msgid "Federation Statistics" msgstr "" -#: src/Module/Admin/Federation.php:193 +#: src/Module/Admin/Federation.php:199 #, php-format msgid "" "Currently this node is aware of %d nodes (%d active users last month, %d " diff --git a/view/templates/admin/federation.tpl b/view/templates/admin/federation.tpl index d99d72e5f..dbee2ec3e 100644 --- a/view/templates/admin/federation.tpl +++ b/view/templates/admin/federation.tpl @@ -63,11 +63,13 @@
    + {{if $c[0]['total']}}
  • {{$c[0]['totallbl']}}
  • {{/if}} {{if $c[0]['month']}}
  • {{$c[0]['monthlbl']}}
  • {{/if}} {{if $c[0]['halfyear']}}
  • {{$c[0]['halfyearlbl']}}
  • {{/if}} {{if $c[0]['users']}}
  • {{$c[0]['userslbl']}}
  • {{/if}} {{if $c[0]['posts']}}
  • {{$c[0]['postslbl']}}
  • {{/if}} {{if $c[0]['postsuserlbl']}}
  • {{$c[0]['postsuserlbl']}}
  • {{/if}} + {{if $c[0]['userssystemlbl']}}
  • {{$c[0]['userssystemlbl']}}
  • {{/if}}