Fix: The calculation of unseen circles can now be deactivated again

This commit is contained in:
Michael 2023-10-05 17:06:21 +00:00 committed by Jakobus Schürz
parent 428884c621
commit 97fbf70fa6
6 changed files with 21 additions and 10 deletions

View File

@ -1,6 +1,6 @@
-- ------------------------------------------
-- Friendica 2023.09-dev (Giant Rhubarb)
-- DB_UPDATE_VERSION 1534
-- Friendica 2023.09-rc (Giant Rhubarb)
-- DB_UPDATE_VERSION 1535
-- ------------------------------------------

View File

@ -169,16 +169,17 @@ class Circle
*
* Count unread items of each circle of the local user
*
* @param int $uid
* @return array
* 'id' => circle id
* 'name' => circle name
* 'count' => counted unseen circle items
* @throws \Exception
*/
public static function countUnseen()
public static function countUnseen(int $uid)
{
$stmt = DBA::p("SELECT `circle`.`id`, `circle`.`name`,
(SELECT COUNT(*) FROM `post-user-view`
(SELECT COUNT(*) FROM `post-user`
WHERE `uid` = ?
AND `unseen`
AND `contact-id` IN
@ -188,8 +189,8 @@ class Circle
) AS `count`
FROM `group` AS `circle`
WHERE `circle`.`uid` = ?;",
DI::userSession()->getLocalUserId(),
DI::userSession()->getLocalUserId()
$uid,
$uid
);
return DBA::toArray($stmt);

View File

@ -504,7 +504,7 @@ class Site extends BaseAdmin
'$max_display_comments' => ['max_display_comments', DI::l10n()->t('Maximum numbers of comments per post on the display page'), DI::config()->get('system', 'max_display_comments'), DI::l10n()->t('How many comments should be shown on the single view for each post? Default value is 1000.')],
'$temppath' => ['temppath', DI::l10n()->t('Temp path'), DI::config()->get('system', 'temppath'), DI::l10n()->t('If you have a restricted system where the webserver can\'t access the system temp path, enter another path here.')],
'$only_tag_search' => ['only_tag_search', DI::l10n()->t('Only search in tags'), DI::config()->get('system', 'only_tag_search'), DI::l10n()->t('On large systems the text search can slow down the system extremely.')],
'$compute_circle_counts' => ['compute_circle_counts', DI::l10n()->t('Generate counts per contact circle when calculating network count'), DI::config()->get('system', 'compute_group_counts') ?? DI::config()->get('system', 'compute_circle_counts'), DI::l10n()->t('On systems with users that heavily use contact circles the query can be very expensive.')],
'$compute_circle_counts' => ['compute_circle_counts', DI::l10n()->t('Generate counts per contact circle when calculating network count'), DI::config()->get('system', 'compute_circle_counts'), DI::l10n()->t('On systems with users that heavily use contact circles the query can be very expensive.')],
'$worker_queues' => ['worker_queues', DI::l10n()->t('Maximum number of parallel workers'), DI::config()->get('system', 'worker_queues'), DI::l10n()->t('On shared hosters set this to %d. On larger systems, values of %d are great. Default value is %d.', 5, 20, 10)],
'$worker_fastlane' => ['worker_fastlane', DI::l10n()->t('Enable fastlane'), DI::config()->get('system', 'worker_fastlane'), DI::l10n()->t('When enabed, the fastlane mechanism starts an additional worker if processes with higher priority are blocked by processes of lower priority.')],

View File

@ -152,10 +152,10 @@ class Ping extends BaseModule
}
}
$compute_circle_counts = $this->config->get('system','compute_group_counts') ?? $this->config->get('system','compute_circle_counts');
$compute_circle_counts = $this->config->get('system','compute_circle_counts');
if ($network_count && $compute_circle_counts) {
// Find out how unseen network posts are spread across circles
foreach (Circle::countUnseen() as $circle_count) {
foreach (Circle::countUnseen($this->session->getLocalUserId()) as $circle_count) {
if ($circle_count['count'] > 0) {
$circles_unseen[] = $circle_count;
}

View File

@ -56,7 +56,7 @@ use Friendica\Database\DBA;
// This file is required several times during the test in DbaDefinition which justifies this condition
if (!defined('DB_UPDATE_VERSION')) {
define('DB_UPDATE_VERSION', 1534);
define('DB_UPDATE_VERSION', 1535);
}
return [

View File

@ -1388,5 +1388,15 @@ function update_1531()
}
DBA::close($threads);
return Update::SUCCESS;
}
function update_1535()
{
if (DI::config()->get('system', 'compute_group_counts')) {
DI::config()->set('system', 'compute_circle_counts', true);
}
DI::config()->delete('system', 'compute_group_counts');
return Update::SUCCESS;
}