SAAS-1071 - more work on celery backend

This commit is contained in:
Duncan Sommerville 2015-09-22 20:22:06 -04:00
parent ee1ceb9281
commit 55d5fc62a2
5 changed files with 111 additions and 17 deletions

View file

@ -80,14 +80,30 @@ abstract class Application_Service_ThirdPartyCeleryService extends Application_S
/**
* Update a ThirdPartyTrackReferences object for a completed upload
*
* Manipulation and use of the track object is left up to child implementations
*
* @param $task CeleryTasks the completed CeleryTasks object
* @param $trackId int ThirdPartyTrackReferences identifier
* @param $track object third-party service track object
* @param $status string Celery task status
*
* @return ThirdPartyTrackReferences the updated ThirdPartyTrackReferences object
*
* @throws Exception
* @throws PropelException
*/
abstract function updateTrackReference($task, $trackId, $track, $status);
public function updateTrackReference($task, $trackId, $track, $status) {
static::updateTask($task, $status);
$ref = ThirdPartyTrackReferencesQuery::create()
->findOneByDbId($trackId);
if (is_null($ref)) {
$ref = new ThirdPartyTrackReferences();
}
$ref->setDbService(static::$_SERVICE_NAME);
$utc = new DateTimeZone("UTC");
$ref->setDbUploadTime(new DateTime("now", $utc));
$ref->save();
return $ref;
}
}