Refactored session_write_close() optimization and dashboard preloading

hack
This commit is contained in:
Albert Santoni 2015-04-09 13:03:06 -04:00
parent 3e255bfd37
commit 1734cc35c8
7 changed files with 35 additions and 31 deletions

View File

@ -100,6 +100,11 @@ class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
$csrf_namespace->authtoken = sha1(uniqid(rand(),1));
$csrf_namespace->setExpirationSeconds(2*60*60);
}
//Here we are closing the session for writing because otherwise no requests
//in this session will be handled in parallel. This gives a major boost to the perceived performance
//of the application (page load times are more consistent, no lock contention).
session_write_close();
}
/**

View File

@ -405,7 +405,6 @@ class LibraryController extends Zend_Controller_Action
public function contentsFeedAction()
{
session_write_close();
$params = $this->getRequest()->getParams();
# terrible name for the method below. it does not only search files.

View File

@ -123,7 +123,6 @@ class ScheduleController extends Zend_Controller_Action
public function eventFeedAction()
{
session_write_close();
$service_user = new Application_Service_UserService();
$currentUser = $service_user->getCurrentUser();
@ -145,7 +144,6 @@ class ScheduleController extends Zend_Controller_Action
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
$user = new Application_Model_User($userInfo->id);
$editable = $user->isUserType(array(UTYPE_SUPERADMIN, UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER));
session_write_close();
$calendar_interval = Application_Model_Preference::GetCalendarTimeScale();
if ($calendar_interval == "agendaDay") {
@ -164,7 +162,6 @@ class ScheduleController extends Zend_Controller_Action
public function getCurrentShowAction()
{
session_write_close();
$currentShow = Application_Model_Show::getCurrentShow();
if (!empty($currentShow)) {
$this->view->si_id = $currentShow[0]["instance_id"];
@ -304,9 +301,19 @@ class ScheduleController extends Zend_Controller_Action
}
}
/** This is a nasty hack to let us embed the the data the dashboard needs into the HTML response for each page.
* This was originally loaded AFTER page load by AJAX, which is needlessly slow. This should have been templated in.
*/
public static function printCurrentPlaylistForEmbedding()
{
$front = Zend_Controller_Front::getInstance();
$foo = new ScheduleController($front->getRequest(), $front->getResponse());
$foo->getCurrentPlaylistAction();
echo(json_encode($foo->view));
}
public function getCurrentPlaylistAction()
{
session_write_close();
$range = Application_Model_Schedule::GetPlayOrderRangeOld();
$show = Application_Model_Show::getCurrentShow();
@ -715,7 +722,6 @@ class ScheduleController extends Zend_Controller_Action
*/
public function setTimeScaleAction()
{
session_write_close();
Application_Model_Preference::SetCalendarTimeScale($this->_getParam('timeScale'));
}

View File

@ -246,7 +246,6 @@ class ShowbuilderController extends Zend_Controller_Action
public function checkBuilderFeedAction()
{
session_write_close();
$request = $this->getRequest();
$show_filter = intval($request->getParam("showFilter", 0));
$my_shows = intval($request->getParam("myShows", 0));
@ -266,7 +265,6 @@ class ShowbuilderController extends Zend_Controller_Action
public function builderFeedAction()
{
session_write_close();
$current_time = time();
$request = $this->getRequest();

View File

@ -37,7 +37,6 @@ class UsersettingsController extends Zend_Controller_Action
public function setLibraryDatatableAction()
{
session_write_close();
$request = $this->getRequest();
$settings = $request->getParam("settings");
@ -46,7 +45,6 @@ class UsersettingsController extends Zend_Controller_Action
public function getLibraryDatatableAction()
{
session_write_close();
$data = Application_Model_Preference::getCurrentLibraryTableSetting();
if (!is_null($data)) {
$this->view->settings = $data;
@ -55,7 +53,6 @@ class UsersettingsController extends Zend_Controller_Action
public function setTimelineDatatableAction()
{
session_write_close();
$request = $this->getRequest();
$settings = $request->getParam("settings");
@ -64,7 +61,6 @@ class UsersettingsController extends Zend_Controller_Action
public function getTimelineDatatableAction()
{
session_write_close();
$data = Application_Model_Preference::getTimelineDatatableSetting();
if (!is_null($data)) {
$this->view->settings = $data;

View File

@ -19,23 +19,6 @@ j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
})(window,document,'script','dataLayer','GTM-55N6NH');</script>
<!-- End Google Tag Manager -->
<script type="text/javascript">
//Awful hack to speed up loading - Embed the schedule in the response so that the dashboard
//doesn't have to make a separate AJAX request to get this data.
var schedulePreLoaded = <?php
require_once("ScheduleController.php");
$front = Zend_Controller_Front::getInstance();
$foo = new ScheduleController($front->getRequest(), $front->getResponse());
$foo->getCurrentPlaylistAction();
echo(json_encode($foo->view));
?>;
parseItems(schedulePreLoaded.entries);
parseSourceStatus(schedulePreLoaded.source_status);
parseSwitchStatus(schedulePreLoaded.switch_status);
</script>
<?php echo $this->partial('partialviews/trialBox.phtml', array("is_trial"=>$this->isTrial(), "trial_remain"=> $this->trialRemaining())) ?>
<div id="Panel">
<?php echo $this->versionNotify();
@ -46,6 +29,23 @@ j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
"scheduled_play_switch"=>$sss['scheduled_play'])) ?>
<?php $partial = array('menu.phtml', 'default');
$this->navigation()->menu()->setPartial($partial); ?>
<script type="text/javascript">
var schedulePreLoaded = <?php
//Awful hack to speed up loading - Embed the schedule in the response so that the dashboard
//doesn't have to make a separate AJAX request to get this data.
require_once("ScheduleController.php");
ScheduleController::printCurrentPlaylistForEmbedding();
?>;
//The DOM elements that these calls depend on exist by this point:
parseItems(schedulePreLoaded.entries);
parseSourceStatus(schedulePreLoaded.source_status);
parseSwitchStatus(schedulePreLoaded.switch_status);
</script>
<div id="nav">
<div class="logo"></div>
<div class="personal-block solo">

View File

@ -360,11 +360,11 @@ function windowResize() {
}
function preloadEventFeed () {
var url = baseUrl+'Schedule/event-feed-preload';
var d = new Date();
createFullCalendar({calendarInit: calendarPref});
/*
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});