1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
createsearchcontentstepper.php
См. документацию.
1<?php
2
3namespace Bitrix\Bizproc\Worker\Task;
4
5use Bitrix\Bizproc\Workflow\Task\TaskSearchContentTable;
6use Bitrix\Bizproc\Workflow\Task\TaskTable;
7use Bitrix\Main;
8
10{
11 protected static $moduleId = 'bizproc';
12
13 private const STEP_ROWS_LIMIT = 100;
14
15 public function execute(array &$option)
16 {
17 $lastId = (int)($this->getOuterParams()[0] ?? 0); //deprecated
18 $lastModifiedOption = (int)($this->getOuterParams()[1] ?? 0);
19
20 $oldDate = Main\Type\Date::createFromTimestamp(time() - 180 * 86400);
21
22 $taskQuery = TaskTable::query();
23 $taskQuery->setSelect(['ID', 'WORKFLOW_ID', 'MODIFIED', 'NAME', 'DESCRIPTION']);
24 $taskQuery->setOrder(['MODIFIED' => 'DESC']);
25 $taskQuery->setLimit(self::STEP_ROWS_LIMIT);
26 $taskQuery->where('MODIFIED', '>', $oldDate);
27
28 if ($lastModifiedOption > 0)
29 {
30 $taskQuery->where('MODIFIED', '<=', Main\Type\DateTime::createFromTimestamp($lastModifiedOption));
31 }
32
33 $taskResult = $taskQuery->exec();
34 $modified = null;
35
36 while ($row = $taskResult->fetch())
37 {
38 $modified = $row['MODIFIED'];
39 try
40 {
41 TaskSearchContentTable::add([
42 'TASK_ID' => $row['ID'],
43 'WORKFLOW_ID' => $row['WORKFLOW_ID'],
44 'SEARCH_CONTENT' => $row['NAME'] . ' ' . $row['DESCRIPTION'],
45 ]);
46 }
47 catch (Main\DB\SqlQueryException $e)
48 {
49 //duplicate, ignore
50 }
51 }
52
53 $lastModified = $modified instanceof Main\Type\DateTime ? $modified->getTimestamp() : null;
54
55 if ($lastModified === null)
56 {
57 return self::FINISH_EXECUTION;
58 }
59
60 if ($lastModified === $lastModifiedOption)
61 {
62 --$lastModified; // step one second
63 }
64
65 $this->setOuterParams([$lastId, $lastModified]);
66
67 return self::CONTINUE_EXECUTION;
68 }
69}
static createFromTimestamp($timestamp)
Определения date.php:402
getTimestamp()
Определения date.php:218
getOuterParams()
Определения stepper.php:212
setOuterParams(array $outerParams)
Определения stepper.php:207
if(!\Bitrix\Main\Loader::includeModule('clouds')) $lastId
Определения sync.php:68
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
Определения arrayresult.php:2
Определения collection.php:2
$option
Определения options.php:1711