Skip to content

Commit

Permalink
Merge pull request kaltura#6898 from kaltura/Mercury-13.16.0-PLAT-8691
Browse files Browse the repository at this point in the history
Mercury-13.16.0-PLAT-8691 - Media re purposing dry run refactor
  • Loading branch information
ZurPHP authored Mar 21, 2018
2 parents e428c2a + c982f6a commit 44f14c1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
3 changes: 0 additions & 3 deletions plugins/scheduled_task/batch/ScheduledTaskBatchHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

class ScheduledTaskBatchHelper
{
const MAX_RESULTS_THRESHOLD = 1000;

/**
* @param KalturaClient $client
* @param KalturaScheduledTaskProfile $scheduledTaskProfile
Expand Down Expand Up @@ -37,7 +35,6 @@ public static function getEntriesIdWithSameCreateAtTime($entries, $createAtTime)
$result[] = $entry->id;
}

$result = array_column($result, 'id');
return $result;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
class KScheduledTaskDryRunner extends KJobHandlerWorker
{
const SHARED_TEMP_PATH = "sharedTempPath";
const PAGE_SIZE = 500;
const MAX_RESULTS_THRESHOLD = 1000;

/**
* @var string
Expand Down Expand Up @@ -33,7 +35,7 @@ class KScheduledTaskDryRunner extends KJobHandlerWorker
private $pager;

/**
* @var kalturaFilter
* @var KalturaBaseEntryFilter
*/
private $filter;

Expand Down Expand Up @@ -118,11 +120,11 @@ private function initRunData(KalturaBatchJob $job, KalturaScheduledTaskJobData $
{
$this->initRunFiles();
$profileId = $job->jobObjectId;
$this->maxResults = ($jobData->maxResults) ? $jobData->maxResults : 500;
$this->maxResults = ($jobData->maxResults) ? $jobData->maxResults : self::PAGE_SIZE;
$this->scheduledTaskProfile = $this->getScheduledTaskProfile($profileId);
$this->initClient($jobData, $this->scheduledTaskProfile->partnerId);
$this->pager = new KalturaFilterPager();
$this->pager->pageSize = 500;
$this->pager->pageSize = self::PAGE_SIZE;
$this->pager->pageIndex = 1;
$this->filter = $this->scheduledTaskProfile->objectFilter;
}
Expand All @@ -146,7 +148,7 @@ private function execDryRunInCSVMode($firstPage, KalturaScheduledTaskJobData $jo
$this->writeEntriesToCsv($firstPage->objects);
$count = $resultsCount;
$this->updateFitler($firstPage->objects);
while($resultsCount < $this->maxResults && $count == 500)
while($resultsCount < $this->maxResults && $count == self::PAGE_SIZE)
{
$results = ScheduledTaskBatchHelper::query($this->client, $this->scheduledTaskProfile, $this->pager, $this->filter);
$objects = $results->objects;
Expand All @@ -155,7 +157,7 @@ private function execDryRunInCSVMode($firstPage, KalturaScheduledTaskJobData $jo
{
$resultsCount += $count;
$this->writeEntriesToCsv($objects);
$this->updateFitler($results->objects);
$this->updateFitler($objects);
}
}
}
Expand Down Expand Up @@ -202,7 +204,7 @@ private function execDryRunInListResponseMode($firstPage, KalturaScheduledTaskJo
{
$count = $resultsCount;
$this->updateFitler($firstPage->objects);
while($resultsCount < $this->maxResult && $count == 500)
while($resultsCount < $this->maxResults && $count == self::PAGE_SIZE)
{
$results = ScheduledTaskBatchHelper::query($this->client, $this->scheduledTaskProfile, $this->pager, $this->filter);
$count = count($results->objects);
Expand Down Expand Up @@ -235,7 +237,7 @@ private function execDryRun(KalturaBatchJob $job, KalturaScheduledTaskJobData $j
{
$this->initRunData($job, $jobData);
$firstPage = ScheduledTaskBatchHelper::query($this->client, $this->scheduledTaskProfile, $this->pager, $this->filter);
if($firstPage->totalCount > ScheduledTaskBatchHelper::MAX_RESULTS_THRESHOLD)
if($firstPage->totalCount > self::MAX_RESULTS_THRESHOLD && $this->maxResults > self::MAX_RESULTS_THRESHOLD)
{
$this->execDryRunInCSVMode($firstPage, $jobData);
}
Expand All @@ -253,7 +255,7 @@ private function closeDryRun($jobData)
$this->unimpersonate();
fclose($this->handle);
kFile::moveFile($this->tempFilePath, $this->sharedFilePath);
KalturaLog::info('Temp shared path: '.$this->tempPath);
KalturaLog::info('Temp shared path: '.$this->sharedFilePath);
$jobData->resultsFilePath = $this->sharedFilePath;
}

Expand Down

0 comments on commit 44f14c1

Please sign in to comment.