+ 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;
+ }
+