1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
eventtable.php
См. документацию.
1<?php
2
3namespace Bitrix\Socialnetwork\Internals\EventService;
4
5use Bitrix\Main\ORM\Data\DataManager;
6use Bitrix\Main\ORM\Query\Query;
7use Bitrix\Main\Type\DateTime;
8
26{
27 private const LOST_LIMIT = 50;
28 private const LOST_TTL = 60;
29
30 public static function getTableName(): string
31 {
32 return 'b_sonet_scorer_event';
33 }
34
35 public static function getClass(): string
36 {
37 return static::class;
38 }
39
40 public static function getMap(): array
41 {
42 return [
43 'ID' => [
44 'data_type' => 'integer',
45 'primary' => true,
46 'autocomplete' => true,
47 ],
48 'HID' => [
49 'data_type' => 'string',
50 'required' => true,
51 ],
52 'TYPE' => [
53 'data_type' => 'string',
54 'required' => true,
55 ],
56 'DATA' => [
57 'data_type' => 'text',
58 'required' => true,
59 ],
60 'LOG_DATA' => [
61 'data_type' => 'text',
62 ],
63 'CREATED' => [
64 'data_type' => 'datetime'
65 ],
66 'PROCESSED' => [
67 'data_type' => 'datetime'
68 ],
69 ];
70 }
71
79 public static function markProcessed(array $filter)
80 {
81 $entity = static::getEntity();
82 $connection = $entity->getConnection();
83
84 \CTimeZone::disable();
85 $res = $connection->query(sprintf(
86 'UPDATE %s SET PROCESSED = CURRENT_TIMESTAMP WHERE %s',
87 $connection->getSqlHelper()->quote($entity->getDbTableName()),
88 Query::buildFilterSql($entity, $filter)
89 ));
90 \CTimeZone::enable();
91
92 return $res;
93 }
94
101 public static function hasLostEvents(): bool
102 {
104 'filter' => [
105 '<=PROCESSED' => DateTime::createFromTimestamp(0),
106 ],
107 'limit' => 1
108 ]);
109
110 return $res->getSelectedRowsCount() > 0;
111 }
112
120 public static function getLostEvents(): array
121 {
122 $limit = \COption::GetOptionString('socialnetwork', "sonetLostCountersLimit", 0);
123 if (!$limit)
124 {
125 $limit = self::LOST_LIMIT;
126 }
127
128 \CTimeZone::disable();
130 'filter' => [
131 '<=PROCESSED' => DateTime::createFromTimestamp(0),
132 '<CREATED' => DateTime::createFromTimestamp(time() - self::LOST_TTL)
133 ],
134 'limit' => $limit
135 ]);
136 \CTimeZone::enable();
137
138 $events = [];
139 while ($row = $res->fetch())
140 {
141 $events[] = $row;
142 }
143
144 return $events;
145 }
146
154 public static function deleteList(array $filter)
155 {
156 $entity = static::getEntity();
157 $connection = $entity->getConnection();
158
159 $enabled = \CTimeZone::Enabled();
160 if ($enabled)
161 {
162 \CTimeZone::Disable();
163 }
164
165 $sql = sprintf(
166 'DELETE FROM %s WHERE %s',
167 $connection->getSqlHelper()->quote($entity->getDbTableName()),
168 Query::buildFilterSql($entity, $filter)
169 );
170 $res = $connection->query($sql);
171
172 if ($enabled)
173 {
174 \CTimeZone::Enable();
175 }
176
177 return $res;
178 }
179}
$connection
Определения actionsdefinitions.php:38
static getList(array $parameters=array())
Определения datamanager.php:431
static markProcessed(array $filter)
Определения eventtable.php:79
</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
$filter
Определения iblock_catalog_list.php:54