...Человеческий поиск в разработке...
- Модуль: tasks
- Путь к файлу: ~/bitrix/modules/tasks/lib/internals/project/filter.php
- Класс: BitrixTasksInternalsProjectFilter
- Вызов: Filter::processFilterCounters
public function processFilterCounters(Query $query, string $counter): Query { $query->getFilterHandler()->removeCondition($this->getProjectVisibilityCondition()); $query ->setDistinct(true) ->registerRuntimeField( 'TS', new ReferenceField( 'TS', CounterCounterTable::getEntity(), Join::on('this.ID', 'ref.GROUP_ID')->where('ref.USER_ID', $this->userId), ['join_type' => 'inner'] ) ) ->where( Query::filter() ->whereNotNull('UG.ID') ->whereIn('UG.ROLE', UserToGroupTable::getRolesMember()) ) ; $typesMap = [ 'EXPIRED' => [ 'INCLUDE' => CounterCounterDictionary::MAP_EXPIRED, 'EXCLUDE' => null, ], 'NEW_COMMENTS' => [ 'INCLUDE' => CounterCounterDictionary::MAP_COMMENTS, 'EXCLUDE' => null, ], 'PROJECT_EXPIRED' => [ 'INCLUDE' => array_merge( [CounterCounterDictionary::COUNTER_GROUP_EXPIRED], CounterCounterDictionary::MAP_MUTED_EXPIRED ), 'EXCLUDE' => CounterCounterDictionary::MAP_EXPIRED, ], 'PROJECT_NEW_COMMENTS' => [ 'INCLUDE' => array_merge( [CounterCounterDictionary::COUNTER_GROUP_COMMENTS], CounterCounterDictionary::MAP_MUTED_COMMENTS ), 'EXCLUDE' => CounterCounterDictionary::MAP_COMMENTS, ], ]; $type = $typesMap[$counter]; $condition = Query::filter()->whereIn('TS.TYPE', $type['INCLUDE']); if ($type['EXCLUDE']) { $typesToExclude = "('" . implode("','", $type['EXCLUDE']) . "')"; $query->registerRuntimeField( 'EXCLUDED_COUNTER_EXISTS', new ExpressionField( 'EXCLUDED_COUNTER_EXISTS', "( SELECT 1 FROM b_tasks_scorer WHERE GROUP_ID = %s AND TASK_ID = %s AND USER_ID = {$this->userId} AND TYPE IN {$typesToExclude} LIMIT 1 )", ['ID', 'TS.TASK_ID'] ) ); $condition->whereNull('EXCLUDED_COUNTER_EXISTS'); } $query->where($condition); return $query; }