|
From: <gem...@li...> - 2012-05-04 12:49:58
|
Revision: 670
http://gemstracker.svn.sourceforge.net/gemstracker/?rev=670&view=rev
Author: mennodekker
Date: 2012-05-04 12:49:48 +0000 (Fri, 04 May 2012)
Log Message:
-----------
Speed up overview pages by only checking tokens for the organization we are working with
also trying if we can move away form $tracker->processTokens
Modified Paths:
--------------
trunk/library/classes/Gems/Default/TokenPlanAction.php
trunk/library/classes/Gems/Tracker/Token.php
trunk/library/classes/Gems/Tracker.php
Modified: trunk/library/classes/Gems/Default/TokenPlanAction.php
===================================================================
--- trunk/library/classes/Gems/Default/TokenPlanAction.php 2012-05-04 11:51:42 UTC (rev 669)
+++ trunk/library/classes/Gems/Default/TokenPlanAction.php 2012-05-04 12:49:48 UTC (rev 670)
@@ -496,7 +496,10 @@
// MUtil_Model::$verbose = true;
// Check for unprocessed tokens
- $this->loader->getTracker()->processCompletedTokens(null, $this->session->user_id);
+ //$this->loader->getTracker()->processCompletedTokens(null, $this->session->user_id);
+ $filter = $this->getCachedRequestData(true);
+ $orgId = array_key_exists('gto_id_organization', $filter) ? $filter['gto_id_organization'] : null;
+ $this->loader->getTracker()->processCompletedTokensBatch(null, $this->session->user_id, $orgId);
parent::indexAction();
}
Modified: trunk/library/classes/Gems/Tracker/Token.php
===================================================================
--- trunk/library/classes/Gems/Tracker/Token.php 2012-05-04 11:51:42 UTC (rev 669)
+++ trunk/library/classes/Gems/Tracker/Token.php 2012-05-04 12:49:48 UTC (rev 670)
@@ -219,7 +219,7 @@
}
// Update values in this object
- $this->_gemsData = $values + $this->_gemsData;
+ $this->_gemsData = $values + (array) $this->_gemsData;
// return 1;
return $this->db->update('gems__tokens', $values, array('gto_id_token = ?' => $this->_tokenId));
Modified: trunk/library/classes/Gems/Tracker.php
===================================================================
--- trunk/library/classes/Gems/Tracker.php 2012-05-04 11:51:42 UTC (rev 669)
+++ trunk/library/classes/Gems/Tracker.php 2012-05-04 12:49:48 UTC (rev 670)
@@ -757,7 +757,9 @@
*/
public function processCompletedTokens($respondentId, $userId = null)
{
- $userId = $this->_checkUserId($userId);
+ return $this->processCompletedTokensBatch($respondentId, $userId, null);
+
+ /*$userId = $this->_checkUserId($userId);
$tokenSelect = $this->getTokenSelect(true)
->onlyActive()
->forRespondent($respondentId)
@@ -773,8 +775,45 @@
}
return $changes->hasChanged();
+ */
}
+ public function processCompletedTokensBatch($respondentId, $userId = null, $orgId = null)
+ {
+ $userId = $this->_checkUserId($userId);
+ $tokenSelect = $this->getTokenSelect();
+ $tokenSelect->onlyActive()
+ ->forRespondent($respondentId)
+ ->andSurveys(array())
+ ->forWhere('gsu_surveyor_active = 1');
+
+ if (!is_null($orgId)) {
+ $tokenSelect->forWhere('gto_id_organization = ?', $orgId);
+ }
+
+ $batch = $this->loader->getTaskRunnerBatch('completed');
+
+ if (! $batch->isLoaded()) {
+ $statement = $tokenSelect->getSelect()->query();
+ //Process one row at a time to prevent out of memory errors for really big resultsets
+ while ($tokenData = $statement->fetch()) {
+ $tokenId = $tokenData['gto_id_token'];
+ $batch->setTask('Tracker_CheckTokenCompletion', 'tokchk-' . $tokenId, $tokenData, $userId);
+ $batch->addToCounter('tokens');
+ }
+ }
+
+ $batch->runAll();
+ if ($batch->getCounter('resultDataChanges') > 0 || $batch->getCounter('surveyCompletionChanges')>0) {
+ $changed = true;
+ } else {
+ $changed = false;
+ }
+
+ $batch->reset();
+ return $changed;
+ }
+
/**
* Checks the token table to see if there are any answered surveys to be processed
*
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|