1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
userprocessor.php
См. документацию.
1<?php
2
3namespace Bitrix\Socialnetwork\Internals\LiveFeed\Counter\Processor;
4
5use Bitrix\Socialnetwork\Internals\LiveFeed\Counter\Exception\UnknownCounterException;
6use Bitrix\Socialnetwork\Internals\LiveFeed\Counter;
7use Bitrix\Socialnetwork\Internals\LiveFeed\Counter\Queue\Queue;
8use Bitrix\Socialnetwork\Internals\LiveFeed\Counter\Queue\Agent;
9use Bitrix\Socialnetwork\Internals\LiveFeed\Counter\Collector;
10use Bitrix\Socialnetwork\Internals\LiveFeed\Counter\CounterDictionary;
11use Bitrix\Socialnetwork\Internals\LiveFeed\Counter\CounterController;
12use Bitrix\Socialnetwork\Item\Log;
13use Bitrix\Socialnetwork\UserContentViewTable;
14
16{
17 use CommandTrait;
18
19 private int $userId;
20 private ?Collector\UserCollector $userCollector = null;
21 private ?Collector\SonetLogCollector $sonetLogCollector = null;
22
23 private array|null $userSonetLogs = null;
24
25 private static array $instances = [];
26
27 public static function getInstance(int $userId)
28 {
29 if (!array_key_exists($userId, self::$instances))
30 {
31 self::$instances[$userId] = new self($userId);
32 }
33
34 return self::$instances[$userId];
35 }
36
37 private function __construct(int $userId)
38 {
39 $this->userId = $userId;
40 }
41
42 public function readAll(int $groupId = 0): void
43 {
44 $types = [
47 ];
48
49 $itemsToReset = $this->getSonetLogItemsByGroup($groupId);
50
51 self::reset($this->userId, $types, $itemsToReset);
53 }
54
55 public function recountAll(string $counter): void
56 {
58 {
59 throw new UnknownCounterException();
60 }
61
62 $total = $this->getSonetLogCollector()->fetchTotal();
64
65 foreach ((new Collector\Paginator($total, $limit)) as $offset)
66 {
67 $rows = $this->getSonetLogCollector()->fetch($limit, $offset);
68 $this->addToQueue($counter, $rows);
69 }
70
71 (new Agent())->addAgent();
72 }
73
74 public function add(string $counter, array $logIds = []): void
75 {
77 {
78 throw new UnknownCounterException();
79 }
80
81 $counters = $this->getUserCollector()->add($counter, $logIds);
82
83 $counterTypes = [$counter];
84 self::reset($this->userId, $counterTypes, $logIds);
85 $this->batchInsert($counters);
86
87 Counter\State\Factory::getState($this->userId)->updateState($counters, $counterTypes, $logIds);
88 }
89
90 public function recount(string $counter, array $logIds = []): void
91 {
93 {
94 throw new UnknownCounterException();
95 }
96
97 $counters = $this->getUserCollector()->recount($counter, $logIds);
98
99 $counterTypes = [$counter];
100 self::reset($this->userId, $counterTypes, $logIds);
101 $this->batchInsert($counters);
102
103 Counter\State\Factory::getState($this->userId)->updateState($counters, $counterTypes, $logIds);
104 }
105
106 public function seen(string $counter, array $logIds = []): void
107 {
109 {
110 throw new UnknownCounterException();
111 }
112
113 $counters = [];
114 $counterTypes = [$counter];
115 self::reset($this->userId, $counterTypes, $logIds);
116 $this->batchInsert($counters);
117
118 Counter\State\Factory::getState($this->userId)->updateState($counters, $counterTypes, $logIds);
119 }
120
121 private function addToQueue(string $counter, array $logIds): void
122 {
123 Queue::getInstance()->add($this->userId, $counter, $logIds);
124 }
125
126 private function getUserCollector(): Collector\UserCollector
127 {
128 if (!$this->userCollector)
129 {
130 $this->userCollector = Collector\UserCollector::getInstance($this->userId);
131 }
132 return $this->userCollector;
133 }
134
135 private function getSonetLogCollector(): Collector\SonetLogCollector
136 {
137 if (!$this->sonetLogCollector)
138 {
139 $this->sonetLogCollector = Collector\SonetLogCollector::getInstance($this->userId);
140 }
141 return $this->sonetLogCollector;
142 }
143
144 private function getSonetLogItemsByGroup(int $groupId): array
145 {
146 $items = [];
147
148 foreach (Counter\State\Factory::getState($this->userId) as $item)
149 {
150 if ($item['GROUP_ID'] == $groupId)
151 {
152 $items[] = $item['SONET_LOG_ID'];
153 }
154 }
155
156 return $items;
157 }
158}
if(!is_object($USER)||! $USER->IsAuthorized()) $userId
Определения check_mail.php:18
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$counter
Определения options.php:5
$items
Определения template.php:224
$counters
Определения options.php:100
$rows
Определения options.php:264