21 public function execute(array &$result): bool
25 if (!Loader::includeModule(self::$moduleId))
32 $params = Option::get(self::$moduleId, self::OPTION_NAME,
"");
33 $params = ($params !==
"" ? @unserialize($params, [
'allowed_classes' =>
false]) : []);
34 $params = (is_array($params) ? $params : []);
40 "count" => ChatTable::getCount(),
44 if ($params[
"count"] > 0)
46 $result[
"steps"] =
"";
47 $result[
"count"] = $params[
"count"];
49 $ids = ChatTable::getList(
51 'order' => [
'ID' =>
'ASC'],
53 '>ID' => $params[
"lastId"],
62 static function($item) {
68 $idsCount = count($ids);
71 $params[
"lastId"] = $ids[$idsCount - 1];
72 $params[
"number"] += $idsCount;
74 $implodedIds = implode(
',', $ids);
77 SET C.MESSAGE_COUNT = (SELECT COUNT(1) FROM b_im_message M WHERE M.CHAT_ID = C.ID)
78 WHERE C.ID IN (" .$implodedIds.
")
83 Option::set(self::$moduleId, self::OPTION_NAME, serialize($params));
88 Option::delete(self::$moduleId, [
"name" => self::OPTION_NAME]);
91 $result[
"steps"] = $params[
"number"];