CC-4873: Airtime takes 7 seconds to load 32K (very small) from db

-we know what month will be the initial view for the user.
-Provide this data ahead of time via ajax request
This commit is contained in:
Martin Konecny 2013-01-24 12:52:24 -05:00
parent ef806b8357
commit 2f3a30b580
3 changed files with 32 additions and 28 deletions

View file

@ -9,6 +9,7 @@ class ScheduleController extends Zend_Controller_Action
{ {
$ajaxContext = $this->_helper->getHelper('AjaxContext'); $ajaxContext = $this->_helper->getHelper('AjaxContext');
$ajaxContext->addActionContext('event-feed', 'json') $ajaxContext->addActionContext('event-feed', 'json')
->addActionContext('event-feed-preload', 'json')
->addActionContext('make-context-menu', 'json') ->addActionContext('make-context-menu', 'json')
->addActionContext('add-show-dialog', 'json') ->addActionContext('add-show-dialog', 'json')
->addActionContext('add-show', 'json') ->addActionContext('add-show', 'json')
@ -88,30 +89,13 @@ class ScheduleController extends Zend_Controller_Action
$this->view->headLink()->appendStylesheet($baseUrl.'css/showbuilder.css?'.$CC_CONFIG['airtime_version']); $this->view->headLink()->appendStylesheet($baseUrl.'css/showbuilder.css?'.$CC_CONFIG['airtime_version']);
//End Show builder JS/CSS requirements //End Show builder JS/CSS requirements
Application_Model_Schedule::createNewFormSections($this->view); Application_Model_Schedule::createNewFormSections($this->view);
$user = Application_Model_User::getCurrentUser(); $user = Application_Model_User::getCurrentUser();
if ($user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER))) { if ($user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER))) {
$this->view->preloadShowForm = true; $this->view->preloadShowForm = true;
} }
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
$user = new Application_Model_User($userInfo->id);
if ($user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER))) {
$editable = true;
} else {
$editable = false;
}
$calendar_interval = Application_Model_Preference::GetCalendarTimeInterval();
if ($calendar_interval == "agendaDay") {
} else if ($calendar_interval == "agendaWeek") {
} else if ($calendar_interval == "month") {
}
list($start, $end) = Application_Model_Show::getStartEndCurrentMonthView();
$events = &Application_Model_Show::getFullCalendarEvents($start, $end, $editable);
$this->view->headScript()->appendScript( $this->view->headScript()->appendScript(
"var calendarPref = {};\n". "var calendarPref = {};\n".
"calendarPref.weekStart = ".Application_Model_Preference::GetWeekStartDay().";\n". "calendarPref.weekStart = ".Application_Model_Preference::GetWeekStartDay().";\n".
@ -120,7 +104,7 @@ class ScheduleController extends Zend_Controller_Action
"calendarPref.timeScale = '".Application_Model_Preference::GetCalendarTimeScale()."';\n". "calendarPref.timeScale = '".Application_Model_Preference::GetCalendarTimeScale()."';\n".
"calendarPref.timeInterval = ".Application_Model_Preference::GetCalendarTimeInterval().";\n". "calendarPref.timeInterval = ".Application_Model_Preference::GetCalendarTimeInterval().";\n".
"calendarPref.weekStartDay = ".Application_Model_Preference::GetWeekStartDay().";\n". "calendarPref.weekStartDay = ".Application_Model_Preference::GetWeekStartDay().";\n".
"var calendarEvents = ".json_encode($events).";" "var calendarEvents = null;"
); );
} }
@ -133,16 +117,29 @@ class ScheduleController extends Zend_Controller_Action
$userInfo = Zend_Auth::getInstance()->getStorage()->read(); $userInfo = Zend_Auth::getInstance()->getStorage()->read();
$user = new Application_Model_User($userInfo->id); $user = new Application_Model_User($userInfo->id);
if ($user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER))) { $editable = $user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER));
$editable = true;
} else {
$editable = false;
}
$events = &Application_Model_Show::getFullCalendarEvents($start, $end, $editable); $events = &Application_Model_Show::getFullCalendarEvents($start, $end, $editable);
$this->view->events = $events; $this->view->events = $events;
} }
public function eventFeedPreloadAction()
{
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
$user = new Application_Model_User($userInfo->id);
$editable = $user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER));
$calendar_interval = Application_Model_Preference::GetCalendarTimeInterval();
if ($calendar_interval == "agendaDay") {
} else if ($calendar_interval == "agendaWeek") {
} else if ($calendar_interval == "month") {
}
list($start, $end) = Application_Model_Show::getStartEndCurrentMonthView();
$events = &Application_Model_Show::getFullCalendarEvents($start, $end, $editable);
$this->view->events = $events;
}
public function getCurrentShowAction() public function getCurrentShowAction()
{ {
$currentShow = Application_Model_Show::getCurrentShow(); $currentShow = Application_Model_Show::getCurrentShow();

View file

@ -326,6 +326,17 @@ function eventResize( event, dayDelta, minuteDelta, revertFunc, jsEvent, ui, vie
}); });
} }
function preload () {
var url = baseUrl+'Schedule/event-feed-preload';
var d = new Date();
$.post(url, {format: "json", cachep: d.getTime()}, function(json){
calendarEvents = json.events;
createFullCalendar({calendarInit: calendarPref});
});
}
preload();
var initialLoad = true; var initialLoad = true;
function getFullCalendarEvents(start, end, callback) { function getFullCalendarEvents(start, end, callback) {

View file

@ -328,10 +328,6 @@ function alertShowErrorAndReload(){
} }
$(document).ready(function() { $(document).ready(function() {
var data = {};
data.calendarInit = calendarPref;
createFullCalendar(data);
setInterval(checkCalendarSCUploadStatus, 5000); setInterval(checkCalendarSCUploadStatus, 5000);
$.contextMenu({ $.contextMenu({