Метод fetchForMembers
Расположение
Исходный файл метода в Bitrix Framework
~/bitrix/modulesim/lib/V2/Recent/PreviewSource/UnreadFreshnessQuery.php
Исходный код
Сигнатура метода
public function fetchForMembers(array $candidatesByUser, array $scopeChatIds): array
Возвращает:
array
Описание
Multi-user freshness for the fan-out path: one flat statement serves a whole member chunk. Per unread leaf the statement fetches the ancestor id chain (levels 0..maxDepth) and a per-level accessibility flag; the nearest-candidate assignment runs in PHP over each member's own candidate set, so members with different mute/hidden states share the statement. The statement is scoped server-side by the parent collab ids: every candidate is either a collab itself or its direct child, so a leaf can only be assigned when a scope chat appears in its ancestor chain at depth <= maxDepth + 1. That superset predicate keeps the transported rows proportional to the members' unread inside the collab subtrees; the PHP assignment below stays authoritative. The statement's cost grows with a member's portal-wide unread and with nothing else: tens of milliseconds even for a member with tens of thousands of unread rows, flat in the collab's size. The fan-out amortizes it into one statement per member chunk; the single-user read path ({@see fetch}) runs it for one user. The caller bounds the chunk ({@see CollabPreviewSourceResolver::resolveForMembers}). Equivalence to the single-user forms: a leaf counts toward candidate R at depth d iff R is its closest candidate ancestor and every level 1..d is accessible - exactly the nearest-bucket rule of the per-depth queries and the anchored SQL, evaluated per member in {@see assignNearestCandidate}.
Параметры
2| Имя | Тип | По умолчанию | Флаги |
|---|---|---|---|
$candidatesByUser
|
array
|
-
|
-
|
$scopeChatIds
|
array
|
-
|
-
|