- Модуль: tasks
- Путь к файлу: ~/bitrix/modules/tasks/lib/update/fulltasksindexer.php
- Класс: BitrixTasksUpdateFullTasksIndexer
- Вызов: FullTasksIndexer::handleComments
static function handleComments($time, $params)
{
$found = false;
$query = new Query(TaskTable::getEntity());
$query->setSelect([
'TASK_ID' => 'ID',
'MESSAGE_ID' => 'FM.ID',
'POST_MESSAGE' => 'FM.POST_MESSAGE'
]);
$query->registerRuntimeField(
'',
new ReferenceField(
'FM',
MessageTable::class,
Join::on('this.FORUM_TOPIC_ID', 'ref.TOPIC_ID')
->where('ref.NEW_TOPIC', 'N'),
['join_type' => 'INNER']
)
);
$query
->where('FM.ID', '>', $params["last_comment_id"])
;
$query->setOrder(['FM.ID' => 'ASC']);
$query->setOffset(0);
$query->setLimit(100);
$commentsRes = $query->exec();
while ($comment = $commentsRes->fetch())
{
$taskId = $comment['TASK_ID'];
$commentId = $comment['MESSAGE_ID'];
$commentText = $comment['POST_MESSAGE'];
SearchIndex::setCommentSearchIndex($taskId, $commentId, $commentText);
$params["number"]++;
$params["last_comment_id"] = $commentId;
$found = true;
if (time() - $time > 3)
{
break;
}
}
return [
'FOUND' => $found,
'PARAMS' => $params
];
}