mirror of
https://github.com/friendica/friendica
synced 2024-12-22 23:20:16 +00:00
Use activitites and remove unused config
This commit is contained in:
parent
63c8a90880
commit
ca32134830
2 changed files with 24 additions and 9 deletions
|
@ -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;
|
||||
|
|
|
@ -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,
|
||||
],
|
||||
];
|
||||
|
|
Loading…
Reference in a new issue