Add downgrade action to UpgradeController, fix SoundCloud schema and bugs

This commit is contained in:
Duncan Sommerville 2015-06-24 18:38:04 -04:00
parent 8fcaf7fc74
commit 67155b136a
14 changed files with 361 additions and 93 deletions

View file

@ -75,7 +75,7 @@ class CeleryService {
$config = parse_ini_file(Application_Model_RabbitMq::getRmqConfigPath(), true);
$queue = self::$_CELERY_RESULTS_EXCHANGE . "." . $task;
$c = self::_setupCeleryExchange($config, self::$_CELERY_RESULTS_EXCHANGE, $queue);
$message = $c->getAsyncResultMessage($task->getDbName(), $task->getDbId());
$message = $c->getAsyncResultMessage($task->getDbName(), $task->getDbTaskId());
// If the message isn't ready yet (Celery hasn't finished the task),
// only throw an exception if the message has timed out.
@ -85,12 +85,12 @@ class CeleryService {
// track reference here in case it was a deletion that failed, for example.
$task->setDbStatus(CELERY_FAILED_STATUS)->save();
throw new CeleryTimeoutException("Celery task " . $task->getDbName()
. " with ID " . $task->getDbId() . " timed out");
. " with ID " . $task->getDbTaskId() . " timed out");
} else {
// The message hasn't timed out, but it's still false, which means it hasn't been
// sent back from Celery yet.
throw new CeleryException("Waiting on Celery task " . $task->getDbName()
. " with ID " . $task->getDbId());
. " with ID " . $task->getDbTaskId());
}
}
return $message;
@ -147,7 +147,7 @@ class CeleryService {
protected static function _getPendingTasks($taskName, $serviceName) {
$query = CeleryTasksQuery::create()
->filterByDbStatus(CELERY_PENDING_STATUS)
->filterByDbId('', Criteria::NOT_EQUAL);
->filterByDbTaskId('', Criteria::NOT_EQUAL);
if (!empty($taskName)) {
$query->filterByDbName($taskName);
}

View file

@ -69,7 +69,6 @@ class SoundcloudService extends ThirdPartyCeleryService implements OAuth2 {
*/
protected function _getUploadData($file) {
$file = $file->getPropelOrm();
Logging::info($file);
// TODO: Move this into a proper serializer
$trackArray = $this->_serializeTrack($file);
foreach (self::$_SOUNDCLOUD_PREF_FUNCTIONS as $func => $param) {

View file

@ -82,12 +82,8 @@ abstract class ThirdPartyCeleryService extends ThirdPartyService {
*/
protected function _createTaskReference($fileId, $brokerTaskId, $taskName) {
$trackId = $this->createTrackReference($fileId);
// First, check if the track already has an entry in the database
$task = CeleryTasksQuery::create()->findOneByDbTrackReference($trackId);
if (is_null($task)) {
$task = new CeleryTasks();
}
$task->setDbId($brokerTaskId);
$task = new CeleryTasks();
$task->setDbTaskId($brokerTaskId);
$task->setDbName($taskName);
$utc = new DateTimeZone("UTC");
$task->setDbDispatchTime(new DateTime("now", $utc));