1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
user.php
См. документацию.
1<?
2namespace Bitrix\Forum\Statistic;
3
4use Bitrix\Forum\UserTable;
5use Bitrix\Main\Localization\Loc;
6use Bitrix\Main;
7use Bitrix\Forum;
8
9Loc::loadMessages(__FILE__);
10
12{
13 protected static $moduleId = "forum";
14 private static $limit = 10;
15
16 public static function getTitle()
17 {
18 return 'User statistic calculation';
19 }
20
21 public function execute(array &$option)
22 {
23 $option["steps"] = 1;
24 $option["count"] = 1;
25 if (self::do() > 0)
26 {
27 return self::FINISH_EXECUTION;
28 }
29 return self::CONTINUE_EXECUTION;
30 }
31
32 private static function do()
33 {
34 $limit = self::$limit;
36SELECT ID, ENTITY_ID
37FROM b_forum_service_statistic_queue
38WHERE ENTITY_TYPE='USER'
39ORDER BY ID ASC
40LIMIT {$limit}
41SQL
42 );
43
44 $last = null;
45 while (($res = $dbRes->fetch()))
46 {
47 if ($usr = Forum\User::getById($res['ENTITY_ID']))
48 {
49 $usr->calculateStatistic();
50 }
51 $last = $res;
52 }
53
54 if ($last)
55 {
56 Main\Application::getConnection()->queryExecute(<<<SQL
57DELETE FROM b_forum_service_statistic_queue WHERE ID >= {$last['ID']} AND ENTITY_TYPE='USER'
58SQL
59 );
60 }
61 return $limit;
62 }
63
64 public static function runForTopic(int $topicId)
65 {
66 if (Main\Application::getConnection()->getType() === 'pgsql')
67 {
68 Main\Application::getConnection()->queryExecute(<<<SQL
69INSERT INTO b_forum_service_statistic_queue (ENTITY_TYPE, ENTITY_ID)
70SELECT 'USER', AUTHOR_ID
71FROM b_forum_message
72WHERE TOPIC_ID = {$topicId} AND AUTHOR_ID > 0 AND APPROVED='Y'
73GROUP BY AUTHOR_ID
74ON CONFLICT (ENTITY_TYPE, ENTITY_ID) DO NOTHING
75SQL
76 );
77 }
78 else
79 {
80 Main\Application::getConnection()->queryExecute(<<<SQL
81INSERT IGNORE INTO b_forum_service_statistic_queue (ENTITY_TYPE, ENTITY_ID)
82SELECT 'USER', AUTHOR_ID
83FROM b_forum_message
84WHERE TOPIC_ID = {$topicId} AND AUTHOR_ID > 0 AND APPROVED='Y'
85GROUP BY AUTHOR_ID
86SQL
87 );
88 }
89
90 self::bind(0);
91 }
92
93 public static function calcForTopics(array $topicIds)
94 {
95 $topicIds = implode(', ', array_map('intval', $topicIds));
96 if ($topicIds === '')
97 {
98 return;
99 }
100 if (Main\Application::getConnection()->getType() === 'pgsql')
101 {
102 Main\Application::getConnection()->queryExecute(<<<SQL
103INSERT INTO b_forum_service_statistic_queue (ENTITY_TYPE, ENTITY_ID)
104SELECT 'USER', AUTHOR_ID
105FROM b_forum_message
106WHERE TOPIC_ID IN ({$topicIds}) AND AUTHOR_ID > 0 AND APPROVED='Y'
107GROUP BY AUTHOR_ID
108ON CONFLICT (ENTITY_TYPE, ENTITY_ID) DO NOTHING
109SQL
110 );
111 }
112 else
113 {
114 Main\Application::getConnection()->queryExecute(<<<SQL
115INSERT IGNORE INTO b_forum_service_statistic_queue (ENTITY_TYPE, ENTITY_ID)
116SELECT 'USER', AUTHOR_ID
117FROM b_forum_message
118WHERE TOPIC_ID IN ({$topicIds}) AND AUTHOR_ID > 0 AND APPROVED='Y'
119GROUP BY AUTHOR_ID
120SQL
121 );
122 }
123
124 self::bind(300);
125 }
126}
static runForTopic(int $topicId)
Определения user.php:64
static calcForTopics(array $topicIds)
Определения user.php:93
execute(array &$option)
Определения user.php:21
static $moduleId
Определения user.php:13
static getTitle()
Определения user.php:16
static getConnection($name="")
Определения application.php:638
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$res
Определения filter_act.php:7
$option
Определения options.php:1711
$dbRes
Определения yandex_detail.php:168