1C-Bitrix
25.700.0
Загрузка...
Поиск...
Не найдено
user.php
См. документацию.
1
<?
2
namespace
Bitrix\Forum\Statistic;
3
4
use Bitrix\Forum\UserTable;
5
use Bitrix\Main\Localization\Loc;
6
use Bitrix\Main;
7
use Bitrix\Forum;
8
9
Loc::loadMessages(__FILE__);
10
11
class
User
extends
Main\Update\Stepper
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;
35
$dbRes
=
Main\Application::getConnection
()->query(<<<SQL
36
SELECT ID, ENTITY_ID
37
FROM b_forum_service_statistic_queue
38
WHERE ENTITY_TYPE=
'USER'
39
ORDER BY ID ASC
40
LIMIT {$limit}
41
SQL
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
57
DELETE FROM b_forum_service_statistic_queue WHERE ID >= {$last[
'ID'
]} AND ENTITY_TYPE=
'USER'
58
SQL
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
69
INSERT INTO b_forum_service_statistic_queue (ENTITY_TYPE, ENTITY_ID)
70
SELECT
'USER'
, AUTHOR_ID
71
FROM b_forum_message
72
WHERE TOPIC_ID = {$topicId} AND AUTHOR_ID > 0 AND APPROVED=
'Y'
73
GROUP BY AUTHOR_ID
74
ON CONFLICT (ENTITY_TYPE, ENTITY_ID) DO NOTHING
75
SQL
76
);
77
}
78
else
79
{
80
Main\Application::getConnection
()->queryExecute(<<<SQL
81
INSERT IGNORE INTO b_forum_service_statistic_queue (ENTITY_TYPE, ENTITY_ID)
82
SELECT
'USER'
, AUTHOR_ID
83
FROM b_forum_message
84
WHERE TOPIC_ID = {$topicId} AND AUTHOR_ID > 0 AND APPROVED=
'Y'
85
GROUP BY AUTHOR_ID
86
SQL
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
103
INSERT INTO b_forum_service_statistic_queue (ENTITY_TYPE, ENTITY_ID)
104
SELECT
'USER'
, AUTHOR_ID
105
FROM b_forum_message
106
WHERE TOPIC_ID IN ({$topicIds}) AND AUTHOR_ID > 0 AND APPROVED=
'Y'
107
GROUP BY AUTHOR_ID
108
ON CONFLICT (ENTITY_TYPE, ENTITY_ID) DO NOTHING
109
SQL
110
);
111
}
112
else
113
{
114
Main\Application::getConnection
()->queryExecute(<<<SQL
115
INSERT IGNORE INTO b_forum_service_statistic_queue (ENTITY_TYPE, ENTITY_ID)
116
SELECT
'USER'
, AUTHOR_ID
117
FROM b_forum_message
118
WHERE TOPIC_ID IN ({$topicIds}) AND AUTHOR_ID > 0 AND APPROVED=
'Y'
119
GROUP BY AUTHOR_ID
120
SQL
121
);
122
}
123
124
self::bind(300);
125
}
126
}
Bitrix\Forum\Statistic\User
Определения
user.php:12
Bitrix\Forum\Statistic\User\runForTopic
static runForTopic(int $topicId)
Определения
user.php:64
Bitrix\Forum\Statistic\User\calcForTopics
static calcForTopics(array $topicIds)
Определения
user.php:93
Bitrix\Forum\Statistic\User\execute
execute(array &$option)
Определения
user.php:21
Bitrix\Forum\Statistic\User\$moduleId
static $moduleId
Определения
user.php:13
Bitrix\Forum\Statistic\User\getTitle
static getTitle()
Определения
user.php:16
Bitrix\Main\Application\getConnection
static getConnection($name="")
Определения
application.php:638
Bitrix\Main\Update\Stepper
Определения
stepper.php:29
array
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения
file_new.php:804
$res
$res
Определения
filter_act.php:7
Bitrix\Forum
Bitrix\Main
$option
$option
Определения
options.php:1711
$dbRes
$dbRes
Определения
yandex_detail.php:168
bitrix
modules
forum
lib
statistic
user.php
Создано системой
1.14.0