From 8a5c25291ec66ff359ceec163cd1488160989736 Mon Sep 17 00:00:00 2001 From: Duncan Sommerville Date: Wed, 11 Nov 2015 18:52:12 -0500 Subject: [PATCH] Lower poll interval for checking import status of podcast episodes --- airtime_mvc/application/controllers/ApiController.php | 9 +++++++++ airtime_mvc/public/js/airtime/library/library.js | 4 ++-- airtime_mvc/public/js/airtime/library/podcast.js | 5 ++++- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/airtime_mvc/application/controllers/ApiController.php b/airtime_mvc/application/controllers/ApiController.php index ed278a775..3b2c52eb4 100644 --- a/airtime_mvc/application/controllers/ApiController.php +++ b/airtime_mvc/application/controllers/ApiController.php @@ -73,6 +73,7 @@ class ApiController extends Zend_Controller_Action ->addActionContext('update-replay-gain-value' , 'json') ->addActionContext('update-cue-values-by-silan' , 'json') ->addActionContext('get-usability-hint' , 'json') + ->addActionContext('poll-celery' , 'json') ->initContext(); } @@ -100,6 +101,14 @@ class ApiController extends Zend_Controller_Action exit(); } + public function pollCeleryAction() { + $this->view->layout()->disableLayout(); + $this->_helper->viewRenderer->setNoRender(true); + + $taskManager = TaskManager::getInstance(); + $taskManager->runTask(TaskFactory::CELERY); + } + public function versionAction() { $this->_helper->json->sendJson( array( diff --git a/airtime_mvc/public/js/airtime/library/library.js b/airtime_mvc/public/js/airtime/library/library.js index f07876ac3..3539307aa 100644 --- a/airtime_mvc/public/js/airtime/library/library.js +++ b/airtime_mvc/public/js/airtime/library/library.js @@ -1272,10 +1272,10 @@ var AIRTIME = (function(AIRTIME) { var dt = $datatables[table], wrapper = $(dt).closest(".dataTables_wrapper"); if (oTable && typeof oTable.fnClearTable === 'function') { - oTable.fnClearTable(); + oTable.fnClearTable(false); } // Don't redraw if we're switching to another hash for the library table - $.when(redraw && oTable != dt ? dt.fnDraw() : function () {}).done(function () { + $.when(redraw ? dt.fnDraw() : function () {}).done(function () { $("#library_content").find(".dataTables_wrapper").hide(); wrapper.show(); }); diff --git a/airtime_mvc/public/js/airtime/library/podcast.js b/airtime_mvc/public/js/airtime/library/podcast.js index 61adc59cc..889219536 100644 --- a/airtime_mvc/public/js/airtime/library/podcast.js +++ b/airtime_mvc/public/js/airtime/library/podcast.js @@ -463,6 +463,9 @@ var AIRTIME = (function (AIRTIME) { } }); if (pendingRows.length > 0) { + // Manually trigger the Celery task to update the internal + // task reference because the upload will often finish quickly + $.get('/api/poll-celery'); // Fetch the table data if there are pending rows, // then check if any of the pending rows have // succeeded or failed before reloading the table. @@ -484,7 +487,7 @@ var AIRTIME = (function (AIRTIME) { } }); } - }, 10000); // Run every 10 seconds + }, 5000); // Run every 5 seconds }; /**