- Модуль: timeman
- Путь к файлу: ~/bitrix/modules/timeman/lib/update/timemanversion19converter.php
- Класс: BitrixTimemanUpdateTimemanVersion19Converter
- Вызов: TimemanVersion19Converter::migrateTimestampRecordsData
private function migrateTimestampRecordsData()
{
$offset = (int)Option::get(self::$moduleId, $this->entriesOffsetOptionName, 0);
if ($offset === 0)
{
$this->createTemporaryTables();
}
$this->logMessage('migrate Timestamp Records Data started', __LINE__);
while (!$this->isMaxExecutionSecondsExceeded())
{
$records = WorktimeRecordTable::query()
->addSelect('ID')
->addSelect('DATE_START')
->setLimit($this->recordsQueryLimit)
->setOffset($offset)
->addOrder('ID')
->exec()
->fetchAll();
if ($records)
{
$this->updateRecords($records);
}
if (count($records) < $this->recordsQueryLimit)
{
// entries migration is over
Option::set(self::$moduleId, $this->isEntriesTimestampMigrationDoneName, 1);
Application::getConnection()->query("
UPDATE
b_timeman_entries
SET
TIMESTAMP_X = TIMESTAMP_X,
RECORDED_DURATION = IF(
RECORDED_DURATION != 0,
RECORDED_DURATION,
IF(
CURRENT_STATUS = 'PAUSED',
RECORDED_DURATION,
IF(
CURRENT_STATUS != 'CLOSED',
0,
IF(
(CAST(RECORDED_STOP_TIMESTAMP AS SIGNED) - CAST(RECORDED_START_TIMESTAMP AS SIGNED) - CAST(TIME_LEAKS AS SIGNED)) > 0,
CAST(RECORDED_STOP_TIMESTAMP AS SIGNED) - CAST(RECORDED_START_TIMESTAMP AS SIGNED) - CAST(TIME_LEAKS AS SIGNED),
IF(
CAST(RECORDED_STOP_TIMESTAMP AS SIGNED) - CAST(RECORDED_START_TIMESTAMP AS SIGNED) > 0,
CAST(RECORDED_STOP_TIMESTAMP AS SIGNED) - CAST(RECORDED_START_TIMESTAMP AS SIGNED),
0
)
)
)
)
)"
);
break;
}
else
{
$offset = $offset + $this->recordsQueryLimit;
Option::set(self::$moduleId, $this->entriesOffsetOptionName, $offset);
$this->logMessage('migrate Timestamp Records Data offset changed to ' . $offset, __LINE__);
}
}
}