From: Michael Date: Sat, 2 Sep 2023 13:56:54 +0000 (+0000) Subject: Use activitites and remove unused config X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=ca32134830a468c4e0a1de1e013e1deb5d4cbae6;p=friendica.git Use activitites and remove unused config --- diff --git a/src/Module/Conversation/Channel.php b/src/Module/Conversation/Channel.php index 230a9ee8ae..42ca508be5 100644 --- a/src/Module/Conversation/Channel.php +++ b/src/Module/Conversation/Channel.php @@ -238,17 +238,17 @@ class Channel extends BaseModule { if (self::$content == self::WHATSHOT) { if (!is_null(self::$accountType)) { - $condition = ["`comments` >= ? AND `contact-type` = ?", self::getMedianComments(4), self::$accountType]; + $condition = ["(`comments` >= ? OR `activities` >= ?) AND `contact-type` = ?", self::getMedianComments(4), self::getMedianActivities(4), self::$accountType]; } else { - $condition = ["`comments` >= ? AND `contact-type` != ?", self::getMedianComments(4), Contact::TYPE_COMMUNITY]; + $condition = ["(`comments` >= ? OR `activities` >= ?) AND `contact-type` != ?", self::getMedianComments(4), self::getMedianActivities(4), Contact::TYPE_COMMUNITY]; } } elseif (self::$content == self::FORYOU) { $cid = Contact::getPublicIdByUserId(DI::userSession()->getLocalUserId()); $condition = ["(`author-id` IN (SELECT `relation-cid` FROM `contact-relation` WHERE `cid` = ? AND `thread-score` > ?) OR - (`comments` >= ? AND `author-id` IN (SELECT `pid` FROM `account-user-view` WHERE `uid` = ? AND `rel` IN (?, ?))) OR + ((`comments` >= ? OR `activities` >= ?) AND `author-id` IN (SELECT `pid` FROM `account-user-view` WHERE `uid` = ? AND `rel` IN (?, ?))) OR ( `author-id` IN (SELECT `pid` FROM `account-user-view` WHERE `uid` = ? AND `rel` IN (?, ?) AND `notify_new_posts`)))", - $cid, self::getMedianThreadScore($cid, 4), self::getMedianComments(3), DI::userSession()->getLocalUserId(), Contact::FRIEND, Contact::SHARING, + $cid, self::getMedianThreadScore($cid, 4), self::getMedianComments(4), self::getMedianActivities(4), DI::userSession()->getLocalUserId(), Contact::FRIEND, Contact::SHARING, DI::userSession()->getLocalUserId(), Contact::FRIEND, Contact::SHARING]; } elseif (self::$content == self::FOLLOWERS) { $condition = ["`author-id` IN (SELECT `pid` FROM `account-user-view` WHERE `uid` = ? AND `rel` = ?)", DI::userSession()->getLocalUserId(), Contact::FOLLOWER]; @@ -302,7 +302,7 @@ class Channel extends BaseModule private static function getMedianComments(int $divider): int { - $cache_key = 'Channel:getHotPostsItemLimit:' . $divider; + $cache_key = 'Channel:getMedianComments:' . $divider; $comments = DI::cache()->get($cache_key); if (!empty($comments)) { return $comments; @@ -319,6 +319,25 @@ class Channel extends BaseModule return $comments; } + private static function getMedianActivities(int $divider): int + { + $cache_key = 'Channel:getMedianActivities:' . $divider; + $activities = DI::cache()->get($cache_key); + if (!empty($activities)) { + return $activities; + } + + $limit = DBA::count('post-engagement', ["`contact-type` != ? AND `activities` > ?", Contact::TYPE_COMMUNITY, 0]) / $divider; + $post = DBA::selectToArray('post-engagement', ['activities'], ["`contact-type` != ?", Contact::TYPE_COMMUNITY, 0], ['order' => ['activities' => true], 'limit' => [$limit, 1]]); + $activities = $post[0]['activities'] ?? 0; + if (empty($activities)) { + return 0; + } + + DI::cache()->set($cache_key, $activities, Duration::HOUR); + return $activities; + } + private static function getMedianThreadScore(int $cid, int $divider): int { $cache_key = 'Channel:getThreadScore:' . $cid . ':' . $divider; diff --git a/static/defaults.config.php b/static/defaults.config.php index 82cf8e0bcd..f73a3300a1 100644 --- a/static/defaults.config.php +++ b/static/defaults.config.php @@ -804,9 +804,5 @@ return [ // engagement_hours (Integer) // Number of hours posts are held in the engagement table 'engagement_hours' => 24, - - // hot_posts_item_limit (Integer) - // Number of items that are displayed on the "what's hot" channel - 'hot_posts_item_limit' => 100, ], ];