Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion plugins/drop_folder/services/DropFolderFileService.php
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,9 @@ private function newFileAddedOrDetected(KalturaDropFolderFile $dropFolderFile, $
$dbDropFolderFile = $existingDropFolderFile;
break;
case DropFolderFileStatus::DETECTED:
KalturaLog::info('Exisiting file status is DETECTED, updating status to ['.$fileStatus.']');
case DropFolderFileStatus::PROCESSING:
$statusName = $existingDropFolderFile->getStatus() == DropFolderFileStatus::DETECTED ? 'DETECTED' : 'PROCESSING';
KalturaLog::info("Exisiting file status is $statusName, updating status to [$fileStatus]");
$existingDropFolderFile = $dropFolderFile->toUpdatableObject($existingDropFolderFile);
if($existingDropFolderFile->getStatus() != $fileStatus)
$existingDropFolderFile->setStatus($fileStatus);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,13 +223,6 @@ class KalturaEntryVendorTask extends KalturaObject implements IRelatedFilterable
*/
public $externalTaskId;

/**
* Indicates if the task is pay-per-use based on the catalog item
* @var bool
* @readonly
*/
public $isPayPerUse;

private static $map_between_objects = array
(
'id',
Expand Down Expand Up @@ -263,8 +256,7 @@ class KalturaEntryVendorTask extends KalturaObject implements IRelatedFilterable
'serviceType',
'serviceFeature',
'turnAroundTime',
'externalTaskId',
'isPayPerUse'
'externalTaskId'
);

/* (non-PHPdoc)
Expand All @@ -287,13 +279,6 @@ public function toInsertableObject($object_to_fill = null, $props_to_skip = arra

$object_to_fill = parent::toInsertableObject($object_to_fill, $props_to_skip);

// Set isPayPerUse flag based on catalog item
$dbVendorCatalogItem = VendorCatalogItemPeer::retrieveByPK($object_to_fill->getCatalogItemId());
if ($dbVendorCatalogItem)
{
$object_to_fill->setIsPayPerUse($dbVendorCatalogItem->getPayPerUse());
}

$jobData = $this->taskJobData;
if ($this->isScheduled() && !$jobData->scheduledEventId)
{
Expand Down
11 changes: 0 additions & 11 deletions plugins/reach/lib/model/EntryVendorTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ class EntryVendorTask extends BaseEntryVendorTask implements IRelatedObject, IIn
const CUSTOM_DATA_SERVICE_FEATURE = 'serviceFeature';
const CUSTOM_DATA_TURN_AROUND_TIME = 'turnAroundTime';
const CUSTOM_DATA_EXTERNAL_TASK_ID = 'externalTaskId';
const CUSTOM_DATA_IS_PAY_PER_USE = 'isPayPerUse';
const SEVEN_DAYS = 604800;
const BUSINESS_DAY_FRIDAY = 5; //Monday is 1
const BUSINESS_DAY_NEXT_MONDAY = 8;
Expand Down Expand Up @@ -157,11 +156,6 @@ public function setExternalTaskId($v)
$this->putInCustomData(self::CUSTOM_DATA_EXTERNAL_TASK_ID, $v);
}

public function setIsPayPerUse($v)
{
$this->putInCustomData(self::CUSTOM_DATA_IS_PAY_PER_USE, $v);
}


//getters

Expand Down Expand Up @@ -285,11 +279,6 @@ public function getExternalTaskId()
return $this->getFromCustomData(self::CUSTOM_DATA_EXTERNAL_TASK_ID);
}

public function getIsPayPerUse()
{
return $this->getFromCustomData(self::CUSTOM_DATA_IS_PAY_PER_USE, null, false);
}

public function isScheduled()
{
return $this->getTaskJobData() instanceof kScheduledVendorTaskData;
Expand Down
53 changes: 13 additions & 40 deletions plugins/reach/lib/model/data/kVendorCredit.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,49 +150,23 @@ public function isSynced()

public function syncCredit($reachProfileId, $partnerId)
{
$c = new Criteria();
$c->add(EntryVendorTaskPeer::REACH_PROFILE_ID, $reachProfileId , Criteria::EQUAL);
$c->add(EntryVendorTaskPeer::STATUS, array(EntryVendorTaskStatus::PENDING, EntryVendorTaskStatus::PROCESSING, EntryVendorTaskStatus::READY), Criteria::IN);
$c->add(EntryVendorTaskPeer::QUEUE_TIME, $this->getSyncCreditStartDate(), Criteria::GREATER_EQUAL);
$c->add(EntryVendorTaskPeer::PRICE, 0, Criteria::NOT_EQUAL);
$c->add(EntryVendorTaskPeer::PARTNER_ID, $partnerId);
$c->addSelectColumn('SUM('. EntryVendorTaskPeer::PRICE .')');
$this->addAdditionalCriteria($c);

$now = time();
$syncStartDate = $this->getSyncCreditStartDate();
$stmt = EntryVendorTaskPeer::doSelectStmt($c);
$row = $stmt->fetch(PDO::FETCH_NUM);

$totalUsedCredit = $this->getSyncedCredit();
$totalPrice = 0;

/* Query 1: Queue-based (non PPU) */
$queueC = new Criteria();
$queueC->add(EntryVendorTaskPeer::REACH_PROFILE_ID, $reachProfileId);
$queueC->add(EntryVendorTaskPeer::PARTNER_ID, $partnerId);
$queueC->add(EntryVendorTaskPeer::PRICE, 0, Criteria::NOT_EQUAL);
$queueC->add(EntryVendorTaskPeer::STATUS, [EntryVendorTaskStatus::PENDING, EntryVendorTaskStatus::PROCESSING, EntryVendorTaskStatus::READY], Criteria::IN);
$queueC->add(EntryVendorTaskPeer::QUEUE_TIME, $syncStartDate, Criteria::GREATER_EQUAL);

$queueTasks = EntryVendorTaskPeer::doSelect($queueC);

foreach ($queueTasks as $task)
{
if (!$task->getIsPayPerUse())
{
$totalPrice += $task->getPrice();
}
}

/* Query 2: Finish-based (PPU) */
$finishC = new Criteria();
$finishC->add(EntryVendorTaskPeer::REACH_PROFILE_ID, $reachProfileId);
$finishC->add(EntryVendorTaskPeer::PARTNER_ID, $partnerId);
$finishC->add(EntryVendorTaskPeer::PRICE, 0, Criteria::NOT_EQUAL);
$finishC->add(EntryVendorTaskPeer::STATUS, EntryVendorTaskStatus::READY);
$finishC->add(EntryVendorTaskPeer::FINISH_TIME, $syncStartDate, Criteria::GREATER_EQUAL);

$finishedTasks = EntryVendorTaskPeer::doSelect($finishC);

foreach ($finishedTasks as $task)
{
if ($task->getIsPayPerUse())
{
$totalPrice += $task->getPrice();
}
}

if ($totalPrice)
$totalPrice = $row[0];
if($totalPrice)
{
$totalUsedCredit += $totalPrice;
}
Expand All @@ -203,7 +177,6 @@ public function syncCredit($reachProfileId, $partnerId)
return $totalUsedCredit;
}


/***
* @param $includeOverages should return current credit including overageCredit info or not (Default is true)
* @return int
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,11 @@ protected function handleMeetingFiles($meetingFiles, &$fileInStatusProcessingExi
{
$parentEntry = $this->createEntry($meetingFile[self::UUID],
$this->dropFolder->zoomVendorIntegration->enableZoomTranscription, $recordingFile[self::RECORDING_START], $userId);
if (!$parentEntry)
{
KalturaLog::debug("Another system (ZOOM EVENT) is creating the parent entry, skipping drop folder file creation");
continue; // Skip this recording file
}
$this->addDropFolderFile($meetingFile, $recordingFile, $parentEntry->id, true);
}
}
Expand Down Expand Up @@ -318,6 +323,18 @@ protected function getEntryByReferenceId($referenceId)

protected function createEntry($uuid, $enableTranscriptionViaZoom, $recordingStartTime, $userId)
{
if (empty($recordingStartTime))
{
throw new kCoreException("Recording start time is null or empty for UUID: {$uuid}");
}
$lockKey = $uuid . '_' . $recordingStartTime;
$resourceReservation = new kResourceReservation(kZoomRecordingProcessor::ZOOM_LOCK_TTL, true);
if(!$resourceReservation->reserve($lockKey))
{
KalturaLog::debug("Entry creation for {$lockKey} is being processed by another system");
return null; // Let the other system (Event) handle it
}

$newEntry = new KalturaMediaEntry();
$newEntry->sourceType = KalturaSourceType::URL;
$newEntry->mediaType = KalturaMediaType::VIDEO;
Expand Down
21 changes: 19 additions & 2 deletions plugins/vendor/zoom/lib/model/kZoomEventHanlder.php
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,11 @@ protected static function createZoomDropFolderFile(kZoomEvent $event, $dropFolde
{
$parentEntry = self::createEntry($recording->uuid, $partnerId, $zoomVendorIntegration->getEnableZoomTranscription(),
$recordingFile->recordingStart, $conversionProfileId);
if (!$parentEntry)
{
KalturaLog::debug("Another system (Watcher) is creating the parent entry, skipping drop folder file creation");
continue; // Skip this recording file
}
$zoomDropFolderFile->setIsParentEntry(true);
}
}
Expand Down Expand Up @@ -437,14 +442,26 @@ protected static function getEntryByReferenceId($referenceId, $partnerId)

protected static function createEntry($uuid, $partnerId, $enableTranscriptionViaZoom, $recordingStartTime, $conversionProfileId)
{
if (empty($recordingStartTime))
{
throw new kCoreException("Recording start time is null or empty for UUID: {$uuid}");
}
$lockKey = $uuid . '_' . $recordingStartTime;
$resourceReservation = new kResourceReservation(kZoomRecordingProcessor::ZOOM_LOCK_TTL, true);
if(!$resourceReservation->reserve($lockKey))
{
KalturaLog::debug("Entry creation for {$lockKey} is being processed by another system");
return null; // Let the other system (Watcher) handle it
}

$templateEntry = null;
$conversionProfile = conversionProfile2Peer::retrieveByPK($conversionProfileId);
$defaultEntryId = $conversionProfile->getDefaultEntryId();
if($defaultEntryId)
{
$templateEntry = entryPeer::retrieveByPKNoFilter($defaultEntryId, null, false);
}

$newEntry = new entry();
if($templateEntry)
{
Expand Down Expand Up @@ -485,4 +502,4 @@ protected static function retrieveByFolderIdAndStatusesNotInAndName($dropFolderI
return $dropFolderFiles;
}

}
}